java.beans

Class PropertyEditorSupport

public class PropertyEditorSupport extends Object implements PropertyEditor

PropertyEditorSupport helps with PropertyEditors, implementing base functionality that they usually must have but which is a pain to implement. You may extend from this class or use it as a standalone.

This class does not do any painting or actual editing. For that, you must use or extend it. See the PropertyEditor class for better descriptions of what the various methods do.

Since: 1.1

UNKNOWN: updated to 1.5

Constructor Summary
PropertyEditorSupport()
Call this constructor when you are deriving from PropertyEditorSupport.
PropertyEditorSupport(Object source)
Call this constructor when you are using PropertyEditorSupport as a helper object.
Method Summary
voidaddPropertyChangeListener(PropertyChangeListener l)
Adds a property change listener to this property editor.
voidfirePropertyChange()
Notifies people that we've changed, although we don't tell them just how.
StringgetAsText()
Gets the value as text.
ComponentgetCustomEditor()
Returns a custom component to edit the value.
StringgetJavaInitializationString()
Gets the Java initialization String for the current value of the Object.
ObjectgetSource()
Returns the bean that is used as the source of events.
String[]getTags()
Returns a list of possible choices for the value.
ObjectgetValue()
Gets the current value of the property.
booleanisPaintable()
Gets whether this object is paintable or not.
voidpaintValue(Graphics g, Rectangle r)
Paints this object.
voidremovePropertyChangeListener(PropertyChangeListener l)
Removes a property change listener from this property editor.
voidsetAsText(String s)
Sets the value as text.
voidsetSource(Object source)
Sets the bean that is used as the source of events when property changes occur.
voidsetValue(Object newValue)
Sets the current value of the property and a property change event is fired to all registered PropertyChangeListener instances.
booleansupportsCustomEditor()
Finds out whether this property editor supports a custom component to edit its value.

Constructor Detail

PropertyEditorSupport

public PropertyEditorSupport()
Call this constructor when you are deriving from PropertyEditorSupport. Using this constructor the event source is this PropertyEditorSupport instance itself.

Since: 1.5

UNKNOWN: this was protected prior to 1.5

PropertyEditorSupport

public PropertyEditorSupport(Object source)
Call this constructor when you are using PropertyEditorSupport as a helper object. This constructor throws a NullPointerException when source is null, for compatibility reasons with J2SDK 1.5.0 .

Parameters: source The source to use when firing property change events.

Since: 1.5

UNKNOWN: this was protected prior to 1.5

Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l)
Adds a property change listener to this property editor.

Parameters: l the listener to add.

firePropertyChange

public void firePropertyChange()
Notifies people that we've changed, although we don't tell them just how.

getAsText

public String getAsText()
Gets the value as text. In this class, you cannot count on getAsText() doing anything useful, although in this implementation I do toString().

Returns: the value as text.

getCustomEditor

public Component getCustomEditor()
Returns a custom component to edit the value.

Returns: null in this class.

getJavaInitializationString

public String getJavaInitializationString()
Gets the Java initialization String for the current value of the Object. This class returns gibberish or null (though the spec does not say which).

Implementation Note: This class returns the string "@$#^" to make sure the code will be broken, so that you will know to override it when you create your own property editor.

Returns: the Java initialization string.

getSource

public Object getSource()
Returns the bean that is used as the source of events.

Returns: The event source object

Since: 1.5

getTags

public String[] getTags()
Returns a list of possible choices for the value.

Returns: null

getValue

public Object getValue()
Gets the current value of the property.

Returns: the current value of the property.

isPaintable

public boolean isPaintable()
Gets whether this object is paintable or not.

Returns: false

paintValue

public void paintValue(Graphics g, Rectangle r)
Paints this object. This class does nothing in this method.

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener l)
Removes a property change listener from this property editor.

Parameters: l the listener to remove.

setAsText

public void setAsText(String s)
Sets the value as text. In this class, you cannot count on setAsText() doing anything useful across implementations. Implementation Note: In this implementation it checks if the String is "null", and if it is, sets the value to null, otherwise it throws an IllegalArgumentException.

Parameters: s the text to convert to a new value.

Throws: IllegalArgumentException if the text is malformed.

setSource

public void setSource(Object source)
Sets the bean that is used as the source of events when property changes occur. The event source bean is for informational purposes only and should not be changed by the PropertyEditor.

Parameters: source

Since: 1.5

setValue

public void setValue(Object newValue)
Sets the current value of the property and a property change event is fired to all registered PropertyChangeListener instances.

Parameters: newValue The new value for the property.

supportsCustomEditor

public boolean supportsCustomEditor()
Finds out whether this property editor supports a custom component to edit its value.

Returns: false in this class.