java.beans
Class PropertyEditorSupport

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.beans.PropertyEditorSupport
All Implemented Interfaces:
PropertyEditor sample code for java.beans.PropertyEditor definition code for java.beans.PropertyEditor

public class PropertyEditorSupport
extends Object sample code for java.lang.Object definition code for java.lang.Object
implements PropertyEditor sample code for java.beans.PropertyEditor definition code for java.beans.PropertyEditor

This is a support class to help build property editors.

It can be used either as a base class or as a delagatee.


Constructor Summary
PropertyEditorSupport sample code for java.beans.PropertyEditorSupport.PropertyEditorSupport() definition code for java.beans.PropertyEditorSupport.PropertyEditorSupport() ()
          Constructs a PropertyEditorSupport object.
PropertyEditorSupport sample code for java.beans.PropertyEditorSupport.PropertyEditorSupport(java.lang.Object) definition code for java.beans.PropertyEditorSupport.PropertyEditorSupport(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  source)
          Constructs a PropertyEditorSupport object.
 
Method Summary
 void addPropertyChangeListener sample code for java.beans.PropertyEditorSupport.addPropertyChangeListener(java.beans.PropertyChangeListener) definition code for java.beans.PropertyEditorSupport.addPropertyChangeListener(java.beans.PropertyChangeListener) (PropertyChangeListener sample code for java.beans.PropertyChangeListener definition code for java.beans.PropertyChangeListener  listener)
          Register a listener for the PropertyChange event.
 void firePropertyChange sample code for java.beans.PropertyEditorSupport.firePropertyChange() definition code for java.beans.PropertyEditorSupport.firePropertyChange() ()
          Report that we have been modified to any interested listeners.
 String sample code for java.lang.String definition code for java.lang.String getAsText sample code for java.beans.PropertyEditorSupport.getAsText() definition code for java.beans.PropertyEditorSupport.getAsText() ()
          Gets the property value as a string suitable for presentation to a human to edit.
 Component sample code for java.awt.Component definition code for java.awt.Component getCustomEditor sample code for java.beans.PropertyEditorSupport.getCustomEditor() definition code for java.beans.PropertyEditorSupport.getCustomEditor() ()
          A PropertyEditor may chose to make available a full custom Component that edits its property value.
 String sample code for java.lang.String definition code for java.lang.String getJavaInitializationString sample code for java.beans.PropertyEditorSupport.getJavaInitializationString() definition code for java.beans.PropertyEditorSupport.getJavaInitializationString() ()
          This method is intended for use when generating Java code to set the value of the property.
 Object sample code for java.lang.Object definition code for java.lang.Object getSource sample code for java.beans.PropertyEditorSupport.getSource() definition code for java.beans.PropertyEditorSupport.getSource() ()
          Returns the bean that is used as the source of events.
 String sample code for java.lang.String definition code for java.lang.String [] getTags sample code for java.beans.PropertyEditorSupport.getTags() definition code for java.beans.PropertyEditorSupport.getTags() ()
          If the property value must be one of a set of known tagged values, then this method should return an array of the tag values.
 Object sample code for java.lang.Object definition code for java.lang.Object getValue sample code for java.beans.PropertyEditorSupport.getValue() definition code for java.beans.PropertyEditorSupport.getValue() ()
          Gets the value of the property.
 boolean isPaintable sample code for java.beans.PropertyEditorSupport.isPaintable() definition code for java.beans.PropertyEditorSupport.isPaintable() ()
          Determines whether the class will honor the painValue method.
 void paintValue sample code for java.beans.PropertyEditorSupport.paintValue(java.awt.Graphics, java.awt.Rectangle) definition code for java.beans.PropertyEditorSupport.paintValue(java.awt.Graphics, java.awt.Rectangle) (Graphics sample code for java.awt.Graphics definition code for java.awt.Graphics  gfx, Rectangle sample code for java.awt.Rectangle definition code for java.awt.Rectangle  box)
          Paint a representation of the value into a given area of screen real estate.
 void removePropertyChangeListener sample code for java.beans.PropertyEditorSupport.removePropertyChangeListener(java.beans.PropertyChangeListener) definition code for java.beans.PropertyEditorSupport.removePropertyChangeListener(java.beans.PropertyChangeListener) (PropertyChangeListener sample code for java.beans.PropertyChangeListener definition code for java.beans.PropertyChangeListener  listener)
          Remove a listener for the PropertyChange event.
 void setAsText sample code for java.beans.PropertyEditorSupport.setAsText(java.lang.String) definition code for java.beans.PropertyEditorSupport.setAsText(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  text)
          Sets the property value by parsing a given String.
 void setSource sample code for java.beans.PropertyEditorSupport.setSource(java.lang.Object) definition code for java.beans.PropertyEditorSupport.setSource(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  source)
          Sets the source bean.
 void setValue sample code for java.beans.PropertyEditorSupport.setValue(java.lang.Object) definition code for java.beans.PropertyEditorSupport.setValue(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  value)
          Set (or change) the object that is to be edited.
 boolean supportsCustomEditor sample code for java.beans.PropertyEditorSupport.supportsCustomEditor() definition code for java.beans.PropertyEditorSupport.supportsCustomEditor() ()
          Determines whether the propertyEditor can provide a custom editor.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

PropertyEditorSupport sample code for java.beans.PropertyEditorSupport() definition code for java.beans.PropertyEditorSupport()

public PropertyEditorSupport()
Constructs a PropertyEditorSupport object.

Since:
1.5

PropertyEditorSupport sample code for java.beans.PropertyEditorSupport(java.lang.Object) definition code for java.beans.PropertyEditorSupport(java.lang.Object)

public PropertyEditorSupport(Object sample code for java.lang.Object definition code for java.lang.Object  source)
Constructs a PropertyEditorSupport object.

Parameters:
source - the source used for event firing
Since:
1.5
Method Detail

getSource sample code for java.beans.PropertyEditorSupport.getSource() definition code for java.beans.PropertyEditorSupport.getSource()

public Object sample code for java.lang.Object definition code for java.lang.Object  getSource()
Returns the bean that is used as the source of events. If the source has not been explicitly set then this instance of PropertyEditorSupport is returned.

Returns:
the source object or this instance
Since:
1.5

setSource sample code for java.beans.PropertyEditorSupport.setSource(java.lang.Object) definition code for java.beans.PropertyEditorSupport.setSource(java.lang.Object)

public void setSource(Object sample code for java.lang.Object definition code for java.lang.Object  source)
Sets the source bean.

The source bean is used as the source of events for the property changes. This source should be used for information purposes only and should not be modified by the PropertyEditor.

Parameters:
source - source object to be used for events
Since:
1.5

setValue sample code for java.beans.PropertyEditorSupport.setValue(java.lang.Object) definition code for java.beans.PropertyEditorSupport.setValue(java.lang.Object)

public void setValue(Object sample code for java.lang.Object definition code for java.lang.Object  value)
Set (or change) the object that is to be edited.

Specified by:
setValue sample code for java.beans.PropertyEditor.setValue(java.lang.Object) definition code for java.beans.PropertyEditor.setValue(java.lang.Object) in interface PropertyEditor sample code for java.beans.PropertyEditor definition code for java.beans.PropertyEditor
Parameters:
value - The new target object to be edited. Note that this object should not be modified by the PropertyEditor, rather the PropertyEditor should create a new object to hold any modified value.

getValue sample code for java.beans.PropertyEditorSupport.getValue() definition code for java.beans.PropertyEditorSupport.getValue()

public Object sample code for java.lang.Object definition code for java.lang.Object  getValue()
Gets the value of the property.

Specified by:
getValue sample code for java.beans.PropertyEditor.getValue() definition code for java.beans.PropertyEditor.getValue() in interface PropertyEditor sample code for java.beans.PropertyEditor definition code for java.beans.PropertyEditor
Returns:
The value of the property.

isPaintable sample code for java.beans.PropertyEditorSupport.isPaintable() definition code for java.beans.PropertyEditorSupport.isPaintable()

public boolean isPaintable()
Determines whether the class will honor the painValue method.

Specified by:
isPaintable sample code for java.beans.PropertyEditor.isPaintable() definition code for java.beans.PropertyEditor.isPaintable() in interface PropertyEditor sample code for java.beans.PropertyEditor definition code for java.beans.PropertyEditor
Returns:
True if the class will honor the paintValue method.

paintValue sample code for java.beans.PropertyEditorSupport.paintValue(java.awt.Graphics, java.awt.Rectangle) definition code for java.beans.PropertyEditorSupport.paintValue(java.awt.Graphics, java.awt.Rectangle)

public void paintValue(Graphics sample code for java.awt.Graphics definition code for java.awt.Graphics  gfx,
                       Rectangle sample code for java.awt.Rectangle definition code for java.awt.Rectangle  box)
Paint a representation of the value into a given area of screen real estate. Note that the propertyEditor is responsible for doing its own clipping so that it fits into the given rectangle.

If the PropertyEditor doesn't honor paint requests (see isPaintable) this method should be a silent noop.

Specified by:
paintValue sample code for java.beans.PropertyEditor.paintValue(java.awt.Graphics, java.awt.Rectangle) definition code for java.beans.PropertyEditor.paintValue(java.awt.Graphics, java.awt.Rectangle) in interface PropertyEditor sample code for java.beans.PropertyEditor definition code for java.beans.PropertyEditor
Parameters:
gfx - Graphics object to paint into.
box - Rectangle within graphics object into which we should paint.

getJavaInitializationString sample code for java.beans.PropertyEditorSupport.getJavaInitializationString() definition code for java.beans.PropertyEditorSupport.getJavaInitializationString()

public String sample code for java.lang.String definition code for java.lang.String  getJavaInitializationString()
This method is intended for use when generating Java code to set the value of the property. It should return a fragment of Java code that can be used to initialize a variable with the current property value.

Example results are "2", "new Color(127,127,34)", "Color.orange", etc.

Specified by:
getJavaInitializationString sample code for java.beans.PropertyEditor.getJavaInitializationString() definition code for java.beans.PropertyEditor.getJavaInitializationString() in interface PropertyEditor sample code for java.beans.PropertyEditor definition code for java.beans.PropertyEditor
Returns:
A fragment of Java code representing an initializer for the current value.

getAsText sample code for java.beans.PropertyEditorSupport.getAsText() definition code for java.beans.PropertyEditorSupport.getAsText()

public String sample code for java.lang.String definition code for java.lang.String  getAsText()
Gets the property value as a string suitable for presentation to a human to edit.

Specified by:
getAsText sample code for java.beans.PropertyEditor.getAsText() definition code for java.beans.PropertyEditor.getAsText() in interface PropertyEditor sample code for java.beans.PropertyEditor definition code for java.beans.PropertyEditor
Returns:
The property value as a string suitable for presentation to a human to edit.

Returns "null" is the value can't be expressed as a string.

If a non-null value is returned, then the PropertyEditor should be prepared to parse that string back in setAsText().


setAsText sample code for java.beans.PropertyEditorSupport.setAsText(java.lang.String) definition code for java.beans.PropertyEditorSupport.setAsText(java.lang.String)

public void setAsText(String sample code for java.lang.String definition code for java.lang.String  text)
               throws IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException 
Sets the property value by parsing a given String. May raise java.lang.IllegalArgumentException if either the String is badly formatted or if this kind of property can't be expressed as text.

Specified by:
setAsText sample code for java.beans.PropertyEditor.setAsText(java.lang.String) definition code for java.beans.PropertyEditor.setAsText(java.lang.String) in interface PropertyEditor sample code for java.beans.PropertyEditor definition code for java.beans.PropertyEditor
Parameters:
text - The string to be parsed.
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException

getTags sample code for java.beans.PropertyEditorSupport.getTags() definition code for java.beans.PropertyEditorSupport.getTags()

public String sample code for java.lang.String definition code for java.lang.String [] getTags()
If the property value must be one of a set of known tagged values, then this method should return an array of the tag values. This can be used to represent (for example) enum values. If a PropertyEditor supports tags, then it should support the use of setAsText with a tag value as a way of setting the value.

Specified by:
getTags sample code for java.beans.PropertyEditor.getTags() definition code for java.beans.PropertyEditor.getTags() in interface PropertyEditor sample code for java.beans.PropertyEditor definition code for java.beans.PropertyEditor
Returns:
The tag values for this property. May be null if this property cannot be represented as a tagged value.

getCustomEditor sample code for java.beans.PropertyEditorSupport.getCustomEditor() definition code for java.beans.PropertyEditorSupport.getCustomEditor()

public Component sample code for java.awt.Component definition code for java.awt.Component  getCustomEditor()
A PropertyEditor may chose to make available a full custom Component that edits its property value. It is the responsibility of the PropertyEditor to hook itself up to its editor Component itself and to report property value changes by firing a PropertyChange event.

The higher-level code that calls getCustomEditor may either embed the Component in some larger property sheet, or it may put it in its own individual dialog, or ...

Specified by:
getCustomEditor sample code for java.beans.PropertyEditor.getCustomEditor() definition code for java.beans.PropertyEditor.getCustomEditor() in interface PropertyEditor sample code for java.beans.PropertyEditor definition code for java.beans.PropertyEditor
Returns:
A java.awt.Component that will allow a human to directly edit the current property value. May be null if this is not supported.

supportsCustomEditor sample code for java.beans.PropertyEditorSupport.supportsCustomEditor() definition code for java.beans.PropertyEditorSupport.supportsCustomEditor()

public boolean supportsCustomEditor()
Determines whether the propertyEditor can provide a custom editor.

Specified by:
supportsCustomEditor sample code for java.beans.PropertyEditor.supportsCustomEditor() definition code for java.beans.PropertyEditor.supportsCustomEditor() in interface PropertyEditor sample code for java.beans.PropertyEditor definition code for java.beans.PropertyEditor
Returns:
True if the propertyEditor can provide a custom editor.

addPropertyChangeListener sample code for java.beans.PropertyEditorSupport.addPropertyChangeListener(java.beans.PropertyChangeListener) definition code for java.beans.PropertyEditorSupport.addPropertyChangeListener(java.beans.PropertyChangeListener)

public void addPropertyChangeListener(PropertyChangeListener sample code for java.beans.PropertyChangeListener definition code for java.beans.PropertyChangeListener  listener)
Register a listener for the PropertyChange event. The class will fire a PropertyChange value whenever the value is updated.

Specified by:
addPropertyChangeListener sample code for java.beans.PropertyEditor.addPropertyChangeListener(java.beans.PropertyChangeListener) definition code for java.beans.PropertyEditor.addPropertyChangeListener(java.beans.PropertyChangeListener) in interface PropertyEditor sample code for java.beans.PropertyEditor definition code for java.beans.PropertyEditor
Parameters:
listener - An object to be invoked when a PropertyChange event is fired.

removePropertyChangeListener sample code for java.beans.PropertyEditorSupport.removePropertyChangeListener(java.beans.PropertyChangeListener) definition code for java.beans.PropertyEditorSupport.removePropertyChangeListener(java.beans.PropertyChangeListener)

public void removePropertyChangeListener(PropertyChangeListener sample code for java.beans.PropertyChangeListener definition code for java.beans.PropertyChangeListener  listener)
Remove a listener for the PropertyChange event.

Specified by:
removePropertyChangeListener sample code for java.beans.PropertyEditor.removePropertyChangeListener(java.beans.PropertyChangeListener) definition code for java.beans.PropertyEditor.removePropertyChangeListener(java.beans.PropertyChangeListener) in interface PropertyEditor sample code for java.beans.PropertyEditor definition code for java.beans.PropertyEditor
Parameters:
listener - The PropertyChange listener to be removed.

firePropertyChange sample code for java.beans.PropertyEditorSupport.firePropertyChange() definition code for java.beans.PropertyEditorSupport.firePropertyChange()

public void firePropertyChange()
Report that we have been modified to any interested listeners.