所有摆动部件清单

时间:2015-03-21 22:51:46

标签: java swing

是否有任何在线资源列出每个单独的摇摆组件,即任何可以附加某种侦听器的资源。

我环顾四周,但很多资源like this one只向您展示其中一些资源。

CellRendererPane不是JComponent的子类,但您仍然可以附加swing event listener。我正在寻找所有在swing中的类,允许你在swing.event下附加任何一个监听器。

1 个答案:

答案 0 :(得分:2)

  

类类型被读作字符串。

可能是这样的:

import java.lang.reflect.*;

public class ReflectionTest{

public static void main(String[] args)
    throws Exception
{
new ReflectionTest();
}

public ReflectionTest()
    throws Exception
{

//  Class thisClass = ReflectionTest.class;
    Class thisClass = Class.forName("javax.swing.JButton");
    Field[] fields = thisClass.getFields();

    for(int i = 0; i < fields.length; i++)
    {
        System.out.println("Field #" + (i+1) + ": " + fields[i].getName());
    }

//  Method[] methods = thisClass.getDeclaredMethods();
    Method[] methods = thisClass.getMethods();

    for(int i = 0; i < methods.length; i++)
    {
        System.out.println("Method #" + (i+1) + ": " + methods[i].getName());
    }

}

public int Scooby = 1;
public String Doo;

}

如果这没有帮助,那么我不明白这个问题。为什么不提供一个简单的例子来说明你要做的事情。