📄 valdez.java
字号:
import java.awt.*;
import java.beans.*;
import java.io.*;
import java.lang.reflect.*;
public class Valdez {
public static void main (String args[]) {
TextField tf = new TextField ("Hello");
inspect (tf);
}
public static void inspect (Object o) {
inspect (o, System.out);
}
public static void inspect (Object o, OutputStream os) {
inspect (o, new PrintWriter (os));
}
public static void inspect (Object o, Writer w) {
inspect (o, new PrintWriter (w));
}
public static void inspect (Object o, PrintWriter pw) {
try {
Class c = o.getClass();
BeanInfo bi = Introspector.getBeanInfo (c);
EventSetDescriptor esd[] = bi.getEventSetDescriptors();
PropertyDescriptor pd[] = bi.getPropertyDescriptors();
Method readMethod;
pw.println ("Bean Information for: " + c);
for (int i=0;i<pd.length;i++) {
if (i==0) pw.println ("\n\tProperties\n\t----------");
pw.print ("(" + (i+1) + ")\t");
pw.print (pd[i].getName() + " - " + pd[i].getPropertyType());
readMethod = pd[i].getReadMethod();
if (readMethod != null) {
try {
pw.println (" - " + readMethod.invoke (o, (Object[])null));
} catch (IllegalArgumentException e) {
pw.println ("Unable to inspect - Illegal Argument");
} catch (IllegalAccessException e) {
pw.println ("Unable to inspect - Illegal Access");
} catch (InvocationTargetException e) {
pw.println ("Unable to inspect - Invocation Problems");
}
} else {
pw.println ();
}
}
for (int i=0;i<esd.length;i++) {
if (i==0) pw.println ("\n\tListeners\n\t---------");
pw.print ("(" + (i+1) + ")\t");
pw.println (esd[i].getName() + " - " + esd[i].getListenerType());
}
} catch (IntrospectionException e) {
pw.println ("Introspection Error");
}
pw.flush();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -