com.jidesoft.grid
Class EnumCellEditor
java.lang.Object
javax.swing.AbstractCellEditor
com.jidesoft.grid.AbstractJideCellEditor
com.jidesoft.grid.ContextSensitiveCellEditor
com.jidesoft.grid.ExComboBoxCellEditor
com.jidesoft.grid.ListComboBoxCellEditor
com.jidesoft.grid.EnumCellEditor
- All Implemented Interfaces:
- ConverterContextSupport, EditorContextSupport, EditorStyleSupport, JideCellEditor, ActionListener, Serializable, EventListener, CellEditor, PopupMenuListener, TableCellEditor
public class EnumCellEditor
- extends ListComboBoxCellEditor
A cell editor that based on ListComboBoxCellEditor. It use EnumConverter. For example, in SwingConstants, the
following values are defined.
public static final int CENTER = 0;
public static final int TOP = 1;
public static final int LEFT = 2;
public static final int BOTTOM = 3;
public static final int RIGHT = 4;
When you want user to choose one of the value above from a table's cell editor, you don't want to use 0, 1, 2, 3, 4
as the value in combobox as it doesn't mean anything from user point of view. You want user to be able to use
meaningful names such as "Center", "Top", "Left", "Bottom", "Right". This is what EnumCellEditor can do it for you.
First, you need to define a EnumConverter, then register it with ObjectConverterManager. Then define a EnumCellEditor
and register with CellEditorManager. See code example below.
EnumConverter locationConverter = new EnumConverter("Location", int.class,
new Object[]{
new Integer(SwingConstants.CENTER),
new Integer(SwingConstants.TOP),
new Integer(SwingConstants.LEFT),
new Integer(SwingConstants.BOTTOM),
new Integer(SwingConstants.RIGHT)
},
new String[]{
"Center",
"Top",
"Left",
"Bottom",
"Right"
}, new Integer(SwingConstants.HORIZONTAL));
ObjectConverterManager.registerConverter(locationConverter.getType(), locationConverter,
locationConverter.getContext());
EnumCellRenderer locationCellRenderer = new EnumCellRenderer(locationConverter);
CellRendererManager.registerRenderer(locationConverter.getType(), locationCellRenderer,
locationCellRenderer.getContext());
EnumCellEditor locationCellEditor = new EnumCellEditor(locationConverter);
CellEditorManager.registerEditor(locationConverter.getType(), locationCellEditor, locationCellEditor.getContext());
If you want to use the cell editor and renderer you register above, for example in PropertyTable, you just need to
define the property make ConverterContext to be locationConverter .getContext() and EditorContext to be
locationEditor.getContext().
- See Also:
- Serialized Form
Methods inherited from class com.jidesoft.grid.ExComboBoxCellEditor |
actionPerformed, customizeExComboBox, getCellEditorValue, getComboBox, getTableCellEditorComponent, isEditorStyleSupported, popupMenuCanceled, popupMenuWillBecomeInvisible, popupMenuWillBecomeVisible, setCellEditorValue, setConverter, setType, stopCellEditing |
Methods inherited from class com.jidesoft.grid.AbstractJideCellEditor |
addValidationListener, getClickCountToStart, getDefaultErrorBehavior, getValidationListeners, isAutoStopCellEditing, isCellEditable, isPassEnterKeyToTable, removeValidationListener, setAutoStopCellEditing, setClickCountToStart, setDefaultErrorBehavior, setPassEnterKeyToTable, validate |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
EnumCellEditor
public EnumCellEditor(EnumConverter enumConverter)
getContext
public EditorContext getContext()