📄 imagebean4beaninfo.java
字号:
package examples.beans;
import java.beans.*;
import java.lang.reflect.Method;
/** The class contains information about the ImageBean4
* class in a format that is understood by JavaBean
* builder programs like Sun's BeanBox
*/
public class ImageBean4BeanInfo extends SimpleBeanInfo {
/** Create an array of PropertyDescriptor objects
* representing each of the class's properties
* @return The array of PropertyDescriptor objects
*/
public PropertyDescriptor[] getPropertyDescriptors() {
PropertyDescriptor[] pds = null;
try {
pds = new PropertyDescriptor[] {
new PropertyDescriptor( "fillColor",
ImageBean4.class ),
new PropertyDescriptor( "fileName",
ImageBean4.class ),
new PropertyDescriptor( "scaling",
ImageBean4.class ),
new PropertyDescriptor( "preferredSize",
ImageBean4.class,
"getPreferredSize",
null )
};
pds[0].setShortDescription(
"The fill color around the image" );
pds[1].setShortDescription(
"The file containing the image" );
pds[2].setShortDescription(
"How the image should be drawn" );
pds[3].setShortDescription(
"The preferred size of the panel" );
// all properties of this bean are bound
for ( int i=0; i<pds.length; i++ ) {
pds[i].setBound( true );
}
pds[2].setPropertyEditorClass(
ScalingEditor.class );
} catch( IntrospectionException ix ) {
System.out.println( ix );
return super.getPropertyDescriptors();
}
return pds;
}
/** Indicate that the fileName property is the
* default property to be updated by returning
* its index in the PropertyDescriptor array
* obtained from the method
* getPropertyDescriptors
* @return The index of the fileName array
* element
*/
public int getDefaultPropertyIndex() {
return 1; // the filename property index
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -