org.jdesktop.swingx.editors
Class EnumPropertyEditor<E extends Enum<E>>

java.lang.Object
  extended by java.beans.PropertyEditorSupport
      extended by org.jdesktop.swingx.editors.EnumPropertyEditor<E>
All Implemented Interfaces:
PropertyEditor
Direct Known Subclasses:
AbstractAreaPainterBeanInfo.StylePropertyEditor, AbstractLayoutPainterBeanInfo.HorizontalAlignmentPropertyEditor, AbstractLayoutPainterBeanInfo.VerticalAlignmentPropertyEditor, AbstractPainterBeanInfo.InterpolationPropertyEditor, GlossPainterBeanInfo.GlossPositionPropertyEditor, ImagePainterBeanInfo.ScaleTypePropertyEditor, JXCollapsiblePaneBeanInfo.DirectionPropertyEditor, JXFrameBeanInfo.StartPositionPropertyEditor, JXHeaderBeanInfo.IconPositionPropertyEditor, NeonBorderEffectBeanInfo.BorderPositionPropertyEditor

public class EnumPropertyEditor<E extends Enum<E>>
extends PropertyEditorSupport


Constructor Summary
EnumPropertyEditor(Class<E> en)
          Creates a new instance of EnumPropertyEditor
 
Method Summary
 String getAsText()
          Gets the property value as a string suitable for presentation to a human to edit.
 String getJavaInitializationString()
          This method is intended for use when generating Java code to set the value of the property.
 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.
 void setAsText(String text)
          Sets the property value by parsing a given String.
 
Methods inherited from class java.beans.PropertyEditorSupport
addPropertyChangeListener, firePropertyChange, getCustomEditor, getSource, getValue, isPaintable, paintValue, removePropertyChangeListener, setSource, setValue, supportsCustomEditor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EnumPropertyEditor

public EnumPropertyEditor(Class<E> en)
Creates a new instance of EnumPropertyEditor

Method Detail

getTags

public String[] getTags()
Description copied from class: java.beans.PropertyEditorSupport
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 in interface PropertyEditor
Overrides:
getTags in class PropertyEditorSupport
Returns:
The tag values for this property. May be null if this property cannot be represented as a tagged value.

getAsText

public String getAsText()
Description copied from class: java.beans.PropertyEditorSupport
Gets the property value as a string suitable for presentation to a human to edit.

Specified by:
getAsText in interface PropertyEditor
Overrides:
getAsText in class PropertyEditorSupport
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

public void setAsText(String text)
               throws IllegalArgumentException
Description copied from class: java.beans.PropertyEditorSupport
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 in interface PropertyEditor
Overrides:
setAsText in class PropertyEditorSupport
Parameters:
text - The string to be parsed.
Throws:
IllegalArgumentException

getJavaInitializationString

public String getJavaInitializationString()
Description copied from class: java.beans.PropertyEditorSupport
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 in interface PropertyEditor
Overrides:
getJavaInitializationString in class PropertyEditorSupport
Returns:
A fragment of Java code representing an initializer for the current value.