- Apeendix B -
JavaBeans API
Quick Reference

The JavaBeans API package, also known as java.beans, provides the core classes and interfaces that make the JavaBeans technology possible. The API consists of interfaces, classes, and exceptions, which are covered in detail throughout the rest of this appendix.

Interfaces

The JavaBeans API consists of the following interfaces, which are described in detail throughout the next few sections:

BeanInfo

Extends: Object

The BeanInfo interface defines a set of methods that can be used to find out information explicitly provided by a bean, such as lists of properties, methods, and events. Developers who want to provide explicit bean information must implement the BeanInfo interface and provide suitable information. It's important to note that any information not explicitly provided through the BeanInfo interface is determined by JavaBeans using the automatic introspection facilities of the JavaBeans API. Member Constants

public final static int ICON_COLOR_16x16



This constant represents a 16x16-pixel color icon.

public final static int ICON_COLOR_32x32



This constant represents a 32x32-pixel color icon.

public final static int ICON_MONO_16x16



This constant represents a 16x16-pixel monochrome icon.

public final static int ICON_MONO_32x32



This constant represents a 32x32-pixel monochrome icon. Methods

public abstract BeanDescriptor getBeanDescriptor()



This method gets the bean descriptor associated with a bean.

Returns:

A bean descriptor providing general information about the bean or null if the information should be obtained automatically.

public abstract EventSetDescriptor[] getEventSetDescriptors()



This method gets the array of event set descriptors associated with a bean.

Returns:

An array of event set descriptors describing the kinds of events fired by the bean or null if the information should be obtained automatically.

public abstract int getDefaultEventIndex()



This method gets the default event index for a bean, if it exists.

Returns:

The index of the default event in the event set descriptor array or -1 if there is no default event.

public abstract PropertyDescriptor[] getPropertyDescriptors()



This method gets the array of property descriptors associated with a bean.

Returns:

An array of property descriptors describing the editable properties supported by the bean or null if the information should be obtained automatically.

public abstract int getDefaultPropertyIndex()



This method gets the default property index for a bean, if it exists.

Returns:

The index of the default property in the property descriptor array, or -1 if there is no default property.

public abstract MethodDescriptor[] getMethodDescriptors()



This method gets the array of method descriptors associated with a bean.

Returns:

An array of method descriptors describing the externally visible methods supported by the bean or null if the information should be obtained automatically.

public abstract BeanInfo[] getAdditionalBeanInfo()



This method enables a bean information object to return an arbitrary collection of bean information objects providing additional information on the bean.

Returns:

An array of bean information objects or null if none exist.

public abstract Image getIcon(int iconKind)



This method returns an icon image object that can be used to represent the bean in application builder tools. There are four supported types of icons: 16x16 color, 32x32 color, 16x16 monochrome, and 32x32 monochrome.

Parameter

iconKind The type of icon requested, which is one of the constant values ICON_COLOR_16x16, ICON_COLOR_32x32, ICON_MONO_16x16, or ICON_MONO_32x32

Returns:

An image object representing the requested icon or null if no icon is available.

Customizer

Extends: Object

The Customizer interface defines the overhead required to provide a complete visual editor for a bean. Classes implementing the Customizer interface are typically derived from the Component class so that they can be used in the context of a dialog box or panel. Methods

public abstract void setObject(Object bean)



This method sets the object to be customized.

Parameter

bean The object to be customized.

public abstract void addPropertyChangeListener Â(PropertyChangeListener listener)



This method registers a listener for the PropertyChange event. The customizer should fire the PropertyChange event whenever it modifies the bean in a way that might require the displayed properties to be refreshed.

Parameter

listener A listener to be notified by a PropertyChange event whenever the bean is modified.

public abstract void removePropertyChangeListener Â(PropertyChangeListenerlistener)



This method removes a listener for the PropertyChange event.

Parameter

listener The PropertyChange event listener to be removed.

PropertyChangeListener

Extends: EventListener

The PropertyChangeListener interface serves as the listener interface implemented by classes wanting to receive notifications about a bound property change. This interface consists of the propertyChange() method, which is called whenever the value of a bound property has changed on a bean for which the interface is registered. Methods





public abstract void propertyChange(PropertyChangeEvent evt)



This method is called when a bound property has changed.

Parameter

evt A PropertyChangeEvent object containing information about the event source and the property that has changed.

PropertyEditor

Extends: Object

The PropertyEditor interface defines a means of visually editing a single bean property of a given type. Because JavaBeans provides standard property editors for built-in data types, you are only required to develop property editors for custom data types. Methods

public abstract void setValue(Object value)



This method sets the object that is to be edited.

Parameter

value The target object to be edited.

public abstract Object getValue()



This method gets the object that is being edited.

Returns:

The object being edited.

public abstract boolean isPaintable()



This method determines whether the property can be painted.

Returns:

true if the property can be painted using the paintValue() method; false otherwise.

public abstract void paintValue(Graphics gfx, Rectangle box)



This method paints a representation of the property value into a given area on the screen.

Parameters

gfx The graphics object on which to paint

box A rectangle within the graphics object that specifies the painting window

public abstract String getJavaInitializationString()



This method generates a fragment of Java code that can be used to initialize a variable with the current property value; this method is used when generating Java code to set the value of the property.

Returns:

A fragment of Java code representing an initializer for the current property value.

public abstract String getAsText()



This method gets the property value as a human readable string.

Returns:

The property value as a human readable string or null if the value can't be expressed as a human readable string.

public abstract void setAsText(String text) throws ÂIllegalArgumentException



This method sets the property value by parsing the string argument.

Parameter

text The string to be parsed and set

public abstract String[] getTags()



This method returns an array of tagged values for the property, if they exist.

Returns:

The tagged values for the property or null if the property cannot be represented as tagged values.

public abstract Component getCustomEditor()



This method gets a custom visual property editor for the property.

Returns:

A custom editor that lets a human directly edit the property value or null if there is no custom editor for the property.

public abstract boolean supportsCustomEditor()



This method determines whether a custom editor is supported for the property.

Returns:

true if a custom editor is supported for the property; false otherwise.

public abstract void addPropertyChangeListener Â(PropertyChangeListener listener)



This method registers a listener for the PropertyChange event.

Parameter

listener A listener to be notified when a PropertyChange event is fired.

public abstract void removePropertyChangeListener Â(PropertyChangeListenerlistener)



This method removes a listener from the PropertyChange event.

Parameter

listener The PropertyChange listener to be removed.

VetoableChangeListener

Extends: EventListener

Similar to PropertyChangeListener, the VetoableChangeListener interface serves as the listener interface implemented by classes wanting to receive notifications about a constrained property change. This interface consists of the vetoableChange() method, which is called whenever the value of a constrained property has changed on a bean for which the interface is registered. The vetoableChange() method will throw a PropertyVetoException exception if it rejects the new value of the constrained property. Methods

public abstract void vetoableChange(PropertyChangeEvent evt) Âthrows PropertyVetoException



This method is called when a constrained property has changed.

Parameter

evt A PropertyChangeEvent object containing information about the event source and the property that has changed.

Visibility

Extends: Object

The Visibility interface is used to determine whether a bean requires a graphical user interface and whether a graphical user interface is available for the bean to use. Methods

public abstract boolean needsGui()



This method determines whether the bean needs a graphical user interface.

Returns:

true if the bean needs a graphical user interface available in order to function; false otherwise.

public abstract void dontUseGui()



This method instructs the bean that it should not use the graphical user
interface.

public abstract void okToUseGui()



This method instructs the bean that it is okay to use the graphical user
interface.

public abstract boolean avoidingGui()



This method determines whether the bean is avoiding using the graphical user
interface.

Returns:

true if the bean is avoiding use of the graphical user interface; false
otherwise.

Classes

The JavaBeans API consists of the following classes, which are described in detail throughout the next few sections:

BeanDescriptor

Extends: FeatureDescriptor

The BeanDescriptor class provides global information about a bean, including the name of the bean and the bean's customizer. Constructors

public BeanDescriptor(Class beanClass)



This constructor creates a bean descriptor for a bean that doesn't have a customizer.

Parameter

beanClass The Class object of the Java class that implements the bean.

public BeanDescriptor(Class beanClass, Class customizerClass)



This constructor creates a bean descriptor for a bean that has a customizer.

Parameters

beanClass The Class object of the Java class that implements the bean.

customizerClass The Class object of the Java class that implements the bean's customizer.

Methods

public Class getBeanClass()



This method determines the bean's Class object.

Returns:

The Class object for the bean.

public Class getCustomizerClass()



This method determines the Class object for the bean's customizer.

Returns:

The Class object for the bean's customizer or null if the bean has no customizer.

Beans

Extends: Object

This class provides general-purpose bean utility methods. Constructors

public Beans()



This constructor creates a default bean object. Methods

public static Object instantiate(ClassLoader cls, String name) Âthrows IOException, ClassNotFoundException



This method reads a bean from a serialized object, where the serialized object is a named resource file available from a given class loader.

Parameters

classLoader The class loader from which the serialized object is read or null if the system class loader is to be used.

name The name of the serialized object within the class loader.

public static Object getInstanceOf(Object bean, Class targetType)



This method gets an object representing a specified type view of a bean.

Parameters

bean The bean object from which a view is to be obtained.

targetType The type of view to get.

public static boolean isInstanceOf(Object bean, Class targetType)



This method checks to see whether a bean can be viewed as a given target type.

Parameters

bean The bean from which to obtain a view.

targetType The type of view to get.

Returns:

true if the given bean supports the given targetType; false otherwise.

public static boolean isDesignTime()



This method tests to see whether the bean is in design mode.

Returns:

true if the bean is in design mode; false otherwise.

public static boolean isGuiAvailable()



This method determines whether the bean is running in a graphical
environment.

Returns:

true if the bean is in a graphical environment; false otherwise.

public static void setDesignTime(boolean isDesignTime) throws ÂSecurityException



This method is used to set whether or not the bean is running in an
application builder tool.

Parameter

isDesignTime true if the bean is running in an application builder tool; false otherwise.

public static void setGuiAvailable(boolean isGuiAvailable) throws ÂSecurityException



This method is used to indicate whether the bean is running in a graphical environment.

Parameter

isGuiAvailable true if the bean is running in a graphical
environment.

EventSetDescriptor

Extends: FeatureDescriptor

The EventSetDescriptor class represents a set of events that a bean is capable of generating. The events defined in an EventSetDescriptor class are all deliverable as method calls on a single event listener interface. Constructors

public EventSetDescriptor(Class sourceClass, String eventSetName, ÂClass listenerType, String listenerMethodName) throws



ÂlistenerType, String listenerMethodName) throws  ÂIntrospectionException



This constructor creates an event set descriptor based on the standard design patterns.

Parameters

sourceClass The class firing the event.

eventSetName The programmatic name of the event set.

listenerType The listener to which events will be delivered.

listenerMethodName The name of the method to be called when the event is delivered to its target listener.

public EventSetDescriptor(Class sourceClass, String eventSetName, ÂClass listenerType, String listenerMethodNames[],



ÂString addListenerMethodName, String removeListenerMethodName) 



Âthrows IntrospectionException



This constructor creates a detailed event descriptor using string names.

Parameters

sourceClass The class firing the event.

eventSetName The programmatic name of the
event set.

listenerType The listener to which events will be delivered.

listenerMethodNames The names of the methods to be called when the event is delivered to its target listener.

addListenerMethodName The name of the method on the event source used to register event listeners.

removeListenerMethodName The name of the method on the event source used to remove an event listener.

public EventSetDescriptor(String eventSetName, Class listenerType, ÂMethod listenerMethods[], Method addListenerMethod, Method



ÂremoveListenerMethod)throws IntrospectionException



This constructor creates a detailed event set descriptor using Method and Class objects.

Parameters

eventSetName The programmatic name of the event set.

listenerType The listener to which events will be delivered.

listenerMethods An array of Method objects describing each of the event handling methods in the event listener.

addListenerMethod The method on the event source that is used to register an event listener.

removeListenerMethod The method on the event source that is used to unregister an event listener.

public EventSetDescriptor(String eventSetName, Class listenerType,



ÂMethodDescriptor listenerMethodDescriptors[], 



ÂMethod addListenerMethod, Method removeListenerMethod) 



Âthrows IntrospectionException



This constructor creates a detailed event set descriptor using MethodDescriptor and Class objects.

Parameters

eventSetName The programmatic name of the event set.

listenerType The listener to which events will be delivered.

listenerMethodDescriptors An array of MethodDescriptor objects describing each of the event handling methods in the event listener.

addListenerMethod The method on the event source that is used to register an event listener.

removeListenerMethod The method on the event source that is used to unregister an event listener.

Methods

public Class getListenerType()



This method gets the Class object corresponding to the registered event listener.

Returns:

A Class object for the event listener that is invoked when the event is fired.





public Method[] getListenerMethods()



This method gets the array of Method objects corresponding to the registered event listeners.

Returns:

An array of Method objects for the methods within the event listener that are called when events are fired.

public MethodDescriptor[] getListenerMethodDescriptors()



This method gets the array of MethodDescriptor objects for the methods within the event listener that are called when events are fired.

Returns:

An array of MethodDescriptor objects for the methods within the event listener that are called when events are fired.

public Method getAddListenerMethod()



This method gets the method used to register an event listener.

Returns:

The method used to register an event listener.

public Method getRemoveListenerMethod()



This method gets the method used to remove an event listener.

Returns:

The method used to remove an event listener.

public void setUnicast(boolean unicast)



This method sets an event as unicast.

Parameter

unicast true if the event is to be unicast; false if it is to be multicast.

public boolean isUnicast()



This method determines whether the event is unicast.

Returns:

true if the event set is unicast; false otherwise.

public void setInDefaultEventSet(boolean inDefaultEventSet)



This method sets an event set as being in the default set.

Parameter

inDefaultEventSet true if the event set is to be in the default event set; false otherwise.

public boolean isInDefaultEventSet()



This method determines whether an event set is in the default set.

Returns:

true if the event set is in the default set; false otherwise.

FeatureDescriptor

Extends: Object

The FeatureDescriptor class serves as a common base class for the EventSetDescriptor, MethodDescriptor, and PropertyDescriptor classes. It represents bean information that is common across these classes, such as the name of an event, method, or property. Constructors

public FeatureDescriptor()



This constructor creates a default feature descriptor. Methods

public String getName()



This method gets the programmatic name of the property, method, or event.

Returns:

The programmatic name of the property, method, or event.

public void setName(String name)



This method sets the programmatic name of the property, method, or event.

Parameter

name The programmatic name of the property, method, or event.

public String getDisplayName()



This method gets the localized display name for the property, method, or event.

Returns:

The localized display name for the property, method, or event.

public void setDisplayName(String displayName)



This method sets the localized display name for the property, method, or event.

Parameter

displayName The localized display name for the property, method, or event.

public boolean isExpert()



This method determines whether the expert flag is set for the property, method, or event. The expert flag is used to distinguish between features that are intended for expert users versus those that are intended for normal users.

Returns:

true if the expert flag is set for the property, method, or event; false
otherwise.

public void setExpert(boolean expert)



This method sets the expert flag for the property, method, or event.

Parameter
expert true if this is an expert property, method, or event; false otherwise.

public boolean isHidden()



This method determines whether the hidden flag is set for the property, method, or event. The hidden flag is used to identify features that are intended only for application builder tool use and should not be exposed externally.

Returns:

true if the hidden flag is set for the property, method, or event; false otherwise.

public void setHidden(boolean hidden)



This method sets the hidden flag for the property, method, or event.

Parameter

hidden true if this is a hidden property, method, or event; false otherwise.

public String getShortDescription()



This method gets the localized short description for the property, method, or event.

Returns:

A string representing the localized short description for the property, method, or event.

public void setShortDescription(String text)



This method sets the localized short description for the property, method, or event.

Parameter

text The localized short description for the property, method, or event.

public void setValue(String attributeName, Object value)



This method sets a locale-independent named attribute for the property, method, or event.

Parameters

attributeName The locale-independent name of the attribute to set for the property, method, or event.

value The value of the attribute.





public Object getValue(String attributeName)



This method gets a locale-independent named attribute for the property, method, or event.

Parameter

attributeName The locale-independent name of the attribute for the property, method, or event.

Returns:

The value of the attribute or null if the attribute doesn't exist.





public Enumeration attributeNames()



This method gets an enumeration containing the locale-independent names of any registered attributes for the property, method, or event.

Returns:

An enumeration containing the locale-independent names of any registered attributes for the property, method, or event.

IndexedPropertyDescriptor

Extends: PropertyDescriptor

The IndexedPropertyDescriptor class represents a publicly accessible indexed property. This class provides methods for accessing the type of an indexed property along with its accessor methods. Constructors





public IndexedPropertyDescriptor(String propertyName, Class ÂbeanClass) throws IntrospectionException



This constructor creates an indexed property descriptor for a property that follows standard Java conventions by having getter and setter methods for both indexed and array access.

Parameters

propertyName The programmatic name of the property.

beanClass The Class object for the target bean.





public IndexedPropertyDescriptor(String propertyName, Class ÂbeanClass, String getterName, String setterName,



ÂString indexedGetterName, String indexedSetterName)







Âthrows IntrospectionException



This constructor creates a detailed indexed property descriptor based on the name of the property and method names for getting and setting the property, both indexed and nonindexed.

Parameters

propertyName The programmatic name of the property.

beanClass The Class object for the target bean.

getterName The name of the method used for getting the property values as an array or null if the property is write-only or must be indexed.

setterName The name of the method used for setting the property values as an array or null if the property is read-only or must be indexed.

indexedGetterName The name of the method used for getting an indexed property value or null if the property is write-only.

indexedSetterName The name of the method used for setting an indexed property value or null if the property is read-only.





public IndexedPropertyDescriptor(String propertyName, Method Âgetter, Method setter, Method indexedGetter,



ÂMethod indexedSetter) throws IntrospectionException



This constructor creates a detailed indexed property descriptor based on the name of the property and Method objects for getting and setting the property.

Parameters

propertyName The programmatic name of the property.

getter The method used for getting the property values as an array or null if the property is write-only or must be indexed.

setter The method used for setting the property values as an array or null if the property is read-only or must be indexed.

indexedGetter The method used for getting an indexed property value or null if the property is write-only.

indexedSetter The method used for setting an indexed property value or null if the property is read-only.

Methods





public Method getIndexedReadMethod()



This method gets the method used to get an indexed property value.

Returns:

The method used to get an indexed property value or null if the property isn't indexed or is write-only.





public Method getIndexedWriteMethod()



This method gets the method used to set an indexed property value.

Returns:

The method used to set an indexed property value or null if the property isn't indexed or is read-only.





public Class getIndexedPropertyType()



This method gets the class type of the indexed properties.

Returns:

The class type of the indexed properties.

Introspector

Extends: Object

The Introspector class provides the overhead necessary to analyze a bean and determine its public properties, methods, and events. This class uses explicit bean information if it exists and relies on reflection and design patterns to automatically analyze a bean if not. Methods





public static BeanInfo getBeanInfo(Class beanClass) throws ÂIntrospectionException



This method introspects a Java bean and learns about all its exposed properties, methods, and events.

Parameter

beanClass The bean class to be introspected.

Returns:

A bean information object describing the target bean.





public static BeanInfo getBeanInfo(Class beanClass, Class ÂstopClass) throws IntrospectionException



This method introspects a Java bean below a given stop point and learns about all its exposed properties, methods, and events.

Parameters

beanClass The bean class to be introspected.

stopClass The base class at which to stop the introspection.





public static String decapitalize(String name)



This method converts a string name to standard Java variable name capitalization conventions, which usually means converting the first character from uppercase to lowercase.

Parameter

name The string to be uncapitalized.

Returns:

A string representing the uncapitalized version of the string.





public static String[] getBeanInfoSearchPath()



This method gets an array containing the package names to be searched to find bean information classes.

Returns:

An array containing the package names to be searched to find bean information classes.





public static void setBeanInfoSearchPath(String path[])



This method sets the array of package names to be searched to find bean information classes.

Parameter

path The array of package names to be searched to find bean information classes.

MethodDescriptor

Extends: FeatureDescriptor

The MethodDescriptor class represents a publicly accessible method. This class provides methods for accessing information such as a method's parameters. Constructors





public MethodDescriptor(Method method)



This constructor creates a method descriptor based on the given Method
object.

Parameter

method An object containing low-level method information.





public MethodDescriptor(Method method, ParameterDescriptor



ÂparameterDescriptors[])



This constructor creates a method descriptor based on the given Method object and parameter descriptors.

Parameters

method An object containing low-level method information.

parameterDescriptors An array containing descriptive information for each of the method's parameters.

Methods





public Method getMethod()



This method gets an object containing a low-level description of the method.

Returns:

The low-level description of the method.





public ParameterDescriptor[] getParameterDescriptors()



This method gets an array containing the locale-independent names of the method's parameters.

Returns:

An array containing the locale-independent names of the method's parameters or a null array if the parameter names aren't known.

ParameterDescriptor

Extends: FeatureDescriptor

The ParameterDescriptor class represents the parameters to a method, and is mainly provided as a means for bean developers to provide detailed parameter information beyond that obtained through the Java reflection services. Constructors





public ParameterDescriptor()



This constructor creates a default parameter descriptor object.

PropertyChangeEvent

Extends: EventObject

The PropertyChangeEvent class is used to store information relating to a change in a bound or constrained property. This information consists of the name of the property, the old value of the property, and the new value of the property. PropertyChangeEvent objects are sent as notifications from a bean to registered listeners through the PropertyChangeListener and VetoableChangeListener interfaces, depending on whether the property in question is bound or constrained. More specifically, a PropertyChangeEvent object is sent as the only argument to the propertyChange() and vetoableChange() methods, which are called on the respective listener interfaces. Constructors





public PropertyChangeEvent(Object source, String propertyName, ÂObject oldValue, Object newValue)



This constructor creates a property change event object based on information about the property and the source bean containing the property.

Parameters

source The source bean that contains the property.

propertyName The programmatic name of the property that has changed.

oldValue The old value of the property.

newValue The new value of the property.

Methods





public String getPropertyName()



This method gets the programmatic name of the property that has changed.

Returns:

The programmatic name of the property that has changed or null if multiple properties have changed.





public Object getNewValue()



This method gets the new value for the changed property.

Returns:

The new value for the property, expressed as an object, or null if multiple properties have changed.





public Object getOldValue()



This method gets the old value for the changed property.

Returns:

The old value for the property, expressed as an object, or null if multiple properties have changed.





public void setPropagationId(Object propagationId)



This method sets the propagation identifier for the event.

Parameter

propagationId The propagation identifier for the event.





public Object getPropagationId()



This method gets the propagation identifier for the event.

Returns:

The propagation identifier for the event.

PropertyChangeSupport

Extends: Object

The PropertyChangeSupport class is a helper class for managing listeners of bound and constrained properties. It primarily handles the chore of maintaining a list of listeners and firing property change notifications to each, which is often a nice convenience for beans with bound properties. Constructors





public PropertyChangeSupport(Object sourceBean)



This method creates a default property change support object. Methods





public synchronized void addPropertyChangeListener Â(PropertyChangeListenerlistener)



This method registers a property change event listener.

Parameter

listener The property change event listener to be registered.





public synchronized void removePropertyChangeListener Â(PropertyChangeListenerlistener)



This method removes a property change event listener.

Parameter

listener The property change event listener to be removed.





public void firePropertyChange(String propertyName, Object ÂoldValue, Object newValue)



This method fires a property change event to all registered event listeners.

Parameter

propertyName The programmatic name of the property that has changed.

oldValue The old value of the property.

newValue The new value of the property.

PropertyDescriptor

Extends: FeatureDescriptor

The PropertyDescriptor class represents a publicly accessed property. This class provides methods for accessing the type of a property along with its accessor methods and describes whether it is bound or constrained. Constructors





public PropertyDescriptor(String propertyName, Class beanClass) Âthrows IntrospectionException



This constructor creates a property descriptor for a property that follows the standard Java convention of having getter and setter methods.

Parameters

propertyName The programmatic name of the property.

beanClass The Class object for the bean containing the property.





public PropertyDescriptor(String propertyName, Class beanClass, ÂString getterName, String setterName)







Âthrows IntrospectionException



This constructor creates a property descriptor for a property by specifying the method names used for getting and setting the property.

Parameters

propertyName The programmatic name of the property.

beanClass The Class object for the bean containing the property.

getterName The name of the method used for getting the property value or null if the property is write-only.

setterName The name of the method used for setting the property value or null if the property is read-only.





public PropertyDescriptor(String propertyName, Method getter, ÂMethod setter) throws IntrospectionException



This constructor creates a property descriptor for a property by specifying the methods used for getting and setting the property.

Parameters

propertyName The programmatic name of the property.

getter The method used for getting the property value or null if the property is write-only.

setter The method used for setting the property value or null if the property is read-only.

Methods





public Class getPropertyType()



This method gets the class type for the property.

Returns:

The class type for the property or null if this is an indexed property that doesn't support nonindexed access.





public Method getReadMethod()



This method gets the getter method used to read the property value.

Returns:

The getter method used to read the property value or null if the property can't be read.





public Method getWriteMethod()



This method gets the setter method used to write the property value.

Returns:

The setter method used to write the property value or null if the property can't be written.





public boolean isBound()



This method determines whether the property is bound.

Returns:

true if the property is bound; false otherwise.





public void setBound(boolean bound)



This method sets the property as a bound property.

Parameter

bound true if the property is to be bound; false if not.





public boolean isConstrained()



This method determines whether the property is constrained.

Returns:

true if the property is constrained; false otherwise.





public void setConstrained(boolean constrained)



This method sets the property as a constrained property.

Parameter

constrained true if the property is constrained; false if not.





public void setPropertyEditorClass(Class propertyEditorClass)



This method sets the property editor used for editing the property.

Parameter

propertyEditorClass The property editor used for editing the property.





public Class getPropertyEditorClass()



This method gets the property editor used for editing the property.

Returns:

The property editor used for editing the property or null if no special editor has been registered

PropertyEditorManager

Extends: Object

The PropertyEditorManager class is used to locate the property editor for a property of a given type. Property editors capable of being located by the PropertyEditorManager class must implement the PropertyEditor interface. The PropertyEditorManager class provides a means of registering property types so that their editors can be easily found. For property types that haven't been registered, the PropertyEditorManager class looks for property editors using the name of the property with Editor appended to the end. Constructors





public PropertyEditorManager()



This constructor creates a default property editor manager object. Methods





public static void registerEditor(Class targetType, Class ÂeditorClass)



This method registers an editor class to be used to edit the property values of a given property class.

Parameters

targetType The class type of the property to be edited.

editorClass The property editor class to be used to edit the property values.





public static PropertyEditor findEditor(Class targetType)



This method finds a property editor for a given property class type.

Parameter

targetType The property class type for the property to be edited.

Returns:

A property editor object associated with the given property class or null if no suitable editor can be found.





public static String[] getEditorSearchPath()



This method gets an array containing the package names that are searched in order to find property editors.

Returns:

An array containing the package names that are searched in order to find property editors.





public static void setEditorSearchPath(String path[])



This method sets the array of package names that are searched in order to find property editors.

Parameter

path An array containing the package names that are searched in order to find property editors.

PropertyEditorSupport

Extends: Object

Implements: PropertyEditor

This class is a helper class that implements the PropertyEditor interface that is used to make the construction of custom property editors a little easier. Constructors





protected PropertyEditorSupport()



This constructor creates a default property editor support object and is meant to be used by derived PropertyEditor classes.





PropertyEditorSupport protected PropertyEditorSupport(Object Âsource)



This constructor creates a property editor support object for use when another property editor is delegating information. This constructor is also meant to be used by derived PropertyEditor classes.

Parameter

source The source to use for any events fired by the property editor.

Methods





public void setValue(Object value)



This method sets the value of the property.

Parameter

value The new value of the property.





public Object getValue()



This method gets the value of the property.

Returns:

The value of the property.





public boolean isPaintable()



This method determines whether the property value can be painted.

Returns:

true if the property value can be painted; false otherwise.





public void paintValue(Graphics gfx, Rectangle box)



This method paints a representation of the property value into a given area on the screen.

Parameters

gfx The graphics object to paint on.

box A rectangle within the graphics object that specifies the painting window.





public String getJavaInitializationString()



This method generates a fragment of Java code that can be used to initialize a variable with the current property value; this method is used when generating Java code to set the value of the property.

Returns:

A fragment of Java code representing an initializer for the current property value.





public String getAsText()



This method gets the property value as a human readable string.

Returns:

The property value as a human-readable string or null if the value can't be expressed as a human-readable string.





public void setAsText(String text) throws IllegalArgumentException



This method sets the property value by parsing the string argument.

Parameter

text The string to be parsed and set.





public String[] getTags()



This method returns an array of tagged values for the property, if they exist.

Returns:

The tagged values for the property or null if the property cannot be represented as tagged values.





public Component getCustomEditor()



This method gets a custom visual property editor for the property.

Returns:

A custom editor that enables a human to directly edit the property value or null if there is no custom editor for the property.





public boolean supportsCustomEditor()



This method determines whether a custom editor is supported for the property.

Returns:

true if a custom editor is supported for the property; false otherwise.





public void addPropertyChangeListener(PropertyChangeListener Âlistener)



This method registers a listener for the PropertyChange event.

Parameter

listener A listener to be notified when a PropertyChange event is fired.





public void removePropertyChangeListener(PropertyChangeListener Âlistener)



This method removes a listener for the PropertyChange event.

Parameter

listener The PropertyChange listener to be removed.





public void firePropertyChange()



This method fires a property change event to all registered event listeners.

SimpleBeanInfo

Extends: Object

SimpleBeanInfo is a support class designed to make it easier for bean developers to provide explicit information about a bean. This class basically implements every method in the BeanInfo interface but returns a value that triggers the automatic introspection services. This lets developers provide selective bean information by overriding specific methods, without having to implement every method in the BeanInfo interface. Constructors





public SimpleBeanInfo()



This constructor creates a default simple bean information object. Methods





public BeanDescriptor getBeanDescriptor()



This method denies explicit knowledge of a bean descriptor for the bean, resulting in JavaBeans relying on automatic introspection.

Returns:

A bean descriptor for the bean.





public PropertyDescriptor[] getPropertyDescriptors()



This method denies explicit knowledge of property descriptors for the bean, resulting in JavaBeans relying on automatic introspection.

Returns:

An array containing property descriptors for the bean.





public int getDefaultPropertyIndex()



This method denies explicit knowledge of a default property for the bean, resulting in JavaBeans relying on automatic introspection.

Returns:

The default property for the bean.





public EventSetDescriptor[] getEventSetDescriptors()



This method denies explicit knowledge of event set descriptors for the bean, resulting in JavaBeans relying on automatic introspection.

Returns:

An array containing event set descriptors for the bean.





public int getDefaultEventIndex()



This method denies explicit knowledge of a default event for the bean, resulting in JavaBeans relying on automatic introspection.

Returns:

The default event for the bean.





public MethodDescriptor[] getMethodDescriptors()



This method denies explicit knowledge of method descriptors for the bean, resulting in JavaBeans relying on automatic introspection.

Returns:

An array containing method descriptors for the bean.





public BeanInfo[] getAdditionalBeanInfo()



This method denies explicit knowledge of any other bean information objects for the bean, resulting in JavaBeans relying on automatic introspection.

Returns:

An array containing other bean information objects for the bean.





public Image getIcon(int iconKind)



This method denies explicit knowledge of any icons for the bean, resulting in JavaBeans relying on automatic introspection.

Returns:

The icon for the bean corresponding to the given icon type.





public Image loadImage(String resourceName)



This method is a utility method that loads icon images for a bean based on the name of a resource image file.

Parameter

resourceName A path name for the icon image relative to the directory holding the class file for the bean.

Returns:

An icon image or null if the load failed.

VetoableChangeSupport

Extends: Object

Implements: Serializable

Similar to PropertyChangeSupport, the VetoableChangeSupport class is a helper class for managing listeners of bound and constrained properties. It primarily handles the chore of maintaining a list of listeners and firing property change notifications to each, which is often a nice convenience to beans with constrained properties. Constructors





public VetoableChangeSupport(Object sourceBean)



This method creates a default vetoable change support object. Methods





public synchronized void addVetoableChangeListener Â(VetoableChangeListenerlistener)



This method registers a vetoable change event listener.

Parameter

listener The vetoable change event listener to be registered.





public synchronized void removeVetoableChangeListener Â(VetoableChangeListenerlistener)



This method removes a vetoable change event listener.

Parameter

listener The vetoable change event listener to be removed.





public void fireVetoableChange(String propertyName, Object ÂoldValue, Object newValue) throws PropertyVetoException



This method fires a vetoable change event to all registered event listeners.

Parameters

propertyName The programmatic name of the property that has changed.

oldValue The old value of the property.

newValue The new value of the property.

Exceptions

The JavaBeans API consists of the following exceptions, which are described in detail throughout the next few sections:

IntrospectionException

Extends: Exception

The IntrospectionException exception class signals that an error has occurred during introspection. Examples of situations in which this exception is thrown include not being able to map a string class name to a Class object, not being able to map a string method name to an existing method, and specifying a method name that has the wrong type of signature for its intended use. Constructors





public IntrospectionException(String s)



This constructor creates an introspection exception with the specified detail message, which contains information specific to this particular exception.

Parameter
s The detail message.

PropertyVetoException

Extends: Exception

The PropertyVetoException exception class signals that a veto has occurred on an attempt to change a property value; this exception is thrown only for constrained properties. Constructors





public PropertyVetoException(String s, PropertyChangeEvent e)



This constructor creates a property veto exception with the specified detail message, which contains information specific to this particular exception.

Parameters

s The detail message.

e A property change event indicating the vetoed change.

Methods





public PropertyChangeEvent getPropertyChangeEvent()



This method gets the property change event describing the vetoed change.

Returns:

A property change event indicating the vetoed change.