net.jbeans.bean.property.editor
Class EnumEditor

java.lang.Object
  extended byjava.beans.PropertyEditorSupport
      extended bynet.jbeans.bean.property.editor.EditorSupport
          extended bynet.jbeans.bean.property.editor.EnumEditor
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, java.beans.PropertyEditor

public final class EnumEditor
extends EditorSupport
implements java.awt.event.ActionListener

A property editor for a swing enumerated type. Handles the case in which the PropertyDescriptor has a value for "enumerationValues". Note: the init() method must be called before the set/get methods can be called.

Version:
$Revision: 1.1.1.1 $
Author:
Masahiro Takatsuka (masa@jbeans.net)
See Also:
EditorSupport, ActionListener

Field Summary
 javax.swing.JComboBox combobox
           
 
Fields inherited from class net.jbeans.bean.property.editor.EditorSupport
MEDIUM_DIMENSION, SMALL_DIMENSION
 
Constructor Summary
EnumEditor()
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent evt)
          Event is set when a combo selection changes.
 java.lang.String getJavaInitializationString()
           
 void init(java.beans.PropertyDescriptor descriptor)
          Initializes this property editor with the enumerated items.
 void setValue(java.lang.Object value)
           
 
Methods inherited from class net.jbeans.bean.property.editor.EditorSupport
getCustomEditor, getPanel, setAlignment, setPanel, supportsCustomEditor
 
Methods inherited from class java.beans.PropertyEditorSupport
addPropertyChangeListener, firePropertyChange, getAsText, getTags, getValue, isPaintable, paintValue, removePropertyChangeListener, setAsText
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

combobox

public javax.swing.JComboBox combobox
Constructor Detail

EnumEditor

public EnumEditor()
Method Detail

setValue

public final void setValue(java.lang.Object value)
Specified by:
setValue in interface java.beans.PropertyEditor

getJavaInitializationString

public final java.lang.String getJavaInitializationString()
Specified by:
getJavaInitializationString in interface java.beans.PropertyEditor

init

public final void init(java.beans.PropertyDescriptor descriptor)
Initializes this property editor with the enumerated items. Instances can be shared but there are issues.

This method does a lot of jiggery pokery since enumerated types are unlike any other homogenous types. Enumerated types may not represent the same set of values.

One method would be to empty the list of values which would have the side effect of firing notification events. Another method would be to recreate the combobox.

Overrides:
init in class EditorSupport

actionPerformed

public final void actionPerformed(java.awt.event.ActionEvent evt)
Event is set when a combo selection changes.

Specified by:
actionPerformed in interface java.awt.event.ActionListener


Copyright © 2003 JBean project. All Rights Reserved.