org.peace_tools.views
Class DBClassifierEditor.ColorEditor
java.lang.Object
javax.swing.AbstractCellEditor
org.peace_tools.views.DBClassifierEditor.ColorEditor
- All Implemented Interfaces:
- java.io.Serializable, javax.swing.CellEditor, javax.swing.table.TableCellEditor
- Enclosing class:
- DBClassifierEditor
private class DBClassifierEditor.ColorEditor
- extends javax.swing.AbstractCellEditor
- implements javax.swing.table.TableCellEditor
Custom cell editor to display color chooser dialog to change colors.
This class provides a custom implementation for the color column
displayed by this classifier editor. This class permits the user
to change the color via a color chooser dialog. This class provides
a slightly non-traditional implementation for a cell editor in that
it popups up another dialog for editing cell contents (rather than
permitting the user to modify the contents directly inline in the
table's cell).
Field Summary |
private java.awt.Color |
color
The color value that was last set by the user. |
private static long |
serialVersionUID
The generated serialization UID to keep compiler happy. |
Fields inherited from class javax.swing.AbstractCellEditor |
changeEvent, listenerList |
Method Summary |
java.lang.Object |
getCellEditorValue()
Implementation for method in CellEditor interface to return the
color value set by the user. |
java.awt.Component |
getTableCellEditorComponent(javax.swing.JTable table,
java.lang.Object value,
boolean isSelected,
int row,
int column)
Custom implementation for obtaining cell editor component. |
boolean |
isCellEditable(java.util.EventObject event)
Override default method in parent class to correctly handle
mouse button clicks. |
Methods inherited from class javax.swing.AbstractCellEditor |
addCellEditorListener, cancelCellEditing, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, removeCellEditorListener, shouldSelectCell, stopCellEditing |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface javax.swing.CellEditor |
addCellEditorListener, cancelCellEditing, removeCellEditorListener, shouldSelectCell, stopCellEditing |
color
private java.awt.Color color
- The color value that was last set by the user. This instance
variable is used to pass information between two API methods
getTableCellEditorComponent() and getCellEditorValue()
serialVersionUID
private static final long serialVersionUID
- The generated serialization UID to keep compiler happy.
- See Also:
- Constant Field Values
DBClassifierEditor.ColorEditor
private DBClassifierEditor.ColorEditor()
getTableCellEditorComponent
public java.awt.Component getTableCellEditorComponent(javax.swing.JTable table,
java.lang.Object value,
boolean isSelected,
int row,
int column)
- Custom implementation for obtaining cell editor component.
This method implements the method in AbstractCellEditor interface.
This method is supposed to return the editor component to be displayed
inline in the table's cell to edit the color. However, this method
implements this feature is a different way. Rather than returning an
a component, this method pops up a color chooser dialog that permits
a user to choose the color. Once the color is chosen this method updates
the value in the column.
- Specified by:
getTableCellEditorComponent
in interface javax.swing.table.TableCellEditor
- Parameters:
table
- The JTable that is asking the editor to edit.value
- The value of the cell to be edited. This method assumes that
this value is an Integer object that represents the RGB color values.isSelected
- This value is true if the cell is to be rendered with highlighting.
This parameter is currently unused.row
- The row of the cell being edited.column
- The column of the cell being edited.
- Returns:
- This method always returns null, pretending like there is
no editor to be displayed.
getCellEditorValue
public java.lang.Object getCellEditorValue()
- Implementation for method in CellEditor interface to return the
color value set by the user.
This method returns the color value set by the user for the
given cell.
- Specified by:
getCellEditorValue
in interface javax.swing.CellEditor
- Returns:
- The color value set by the user for this cell.
isCellEditable
public boolean isCellEditable(java.util.EventObject event)
- Override default method in parent class to correctly handle
mouse button clicks.
The default base class always returns true and causes the
dialog to popup whenever the user clicks on a cell. This method
overrides the default implementation to permit the cell to be
editable only after a double click.
- Specified by:
isCellEditable
in interface javax.swing.CellEditor
- Overrides:
isCellEditable
in class javax.swing.AbstractCellEditor
- Returns:
- This method returns true only if the user double clicks on
the column.