Class ComboBoxCellEditor
java.lang.Object
javax.swing.AbstractCellEditor
jmt.framework.gui.table.editors.ComboBoxCellEditor
- All Implemented Interfaces:
Serializable, CellEditor, TableCellEditor, TableCellRenderer
public class ComboBoxCellEditor
extends AbstractCellEditor
implements TableCellEditor, CellEditor, TableCellRenderer
Title: ComboBox Table CellViewer/CellEditor
Description: A component to display a ComboBox as both a viewer and an editor in a table. Internally caches already allocated editors to avoid creation of too many ComboBoxes. Renderer instance is a single element cached too.
- Author:
- Bertoli Marco Date: 9-gen-2006 Time: 9.44.44
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected JComboBoxprotected static HashMap<Object[], ComboBoxCellEditor> protected static final intprotected static ComboBoxCellEditorFields inherited from class AbstractCellEditor
changeEvent, listenerList -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a new ComboBox editor/rendererprotectedComboBoxCellEditor(Object[] items) Creates a new ComboBox editor or renderer basing on given array of items -
Method Summary
Modifier and TypeMethodDescriptionReturns the value contained in the editorstatic ComboBoxCellEditorgetEditorInstance(Object[] items) Returns a new instance of CellEditor that will display items in a ComboBoxstatic ComboBoxCellEditorReturns a new instance of CellRenderer that will display current item in a ComboBoxgetTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) Sets an initialvaluefor the editor.getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) Returns the component used for drawing the cell.Methods inherited from class AbstractCellEditor
addCellEditorListener, cancelCellEditing, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, isCellEditable, removeCellEditorListener, shouldSelectCell, stopCellEditingMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface CellEditor
addCellEditorListener, cancelCellEditing, isCellEditable, removeCellEditorListener, shouldSelectCell, stopCellEditing
-
Field Details
-
MAX_CACHESIZE
protected static final int MAX_CACHESIZE- See Also:
-
editorCache
-
comboBox
-
renderer
-
-
Constructor Details
-
ComboBoxCellEditor
Creates a new ComboBox editor or renderer basing on given array of items- Parameters:
items- array of elements to be shown on the ComboBox
-
ComboBoxCellEditor
protected ComboBoxCellEditor()Creates a new ComboBox editor/renderer
-
-
Method Details
-
getEditorInstance
Returns a new instance of CellEditor that will display items in a ComboBox- Parameters:
items- items to be selected from the ComboBox- Returns:
- CellEditor created or cached copy with the same items
-
getRendererInstance
Returns a new instance of CellRenderer that will display current item in a ComboBox- Returns:
- cached CellRenderer
-
getCellEditorValue
Returns the value contained in the editor- Specified by:
getCellEditorValuein interfaceCellEditor- Returns:
- the value contained in the editor
-
getTableCellEditorComponent
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) Sets an initialvaluefor the editor. This will cause the editor tostopEditingand lose any partially edited value if the editor is editing when this method is called.Returns the component that should be added to the client's
Componenthierarchy. Once installed in the client's hierarchy this component will then be able to draw and receive user input.- Specified by:
getTableCellEditorComponentin interfaceTableCellEditor- Parameters:
table- theJTablethat is asking the editor to edit; can benullvalue- the value of the cell to be edited; it is up to the specific editor to interpret and draw the value. For example, if value is the string "true", it could be rendered as a string or it could be rendered as a check box that is checked.nullis a valid valueisSelected- true if the cell is to be rendered with highlightingrow- the row of the cell being editedcolumn- the column of the cell being edited- Returns:
- the component for editing
-
getTableCellRendererComponent
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) Returns the component used for drawing the cell. This method is used to configure the renderer appropriately before drawing.- Specified by:
getTableCellRendererComponentin interfaceTableCellRenderer- Parameters:
table- theJTablethat is asking the renderer to draw; can benullvalue- the value of the cell to be rendered. It is up to the specific renderer to interpret and draw the value. For example, ifvalueis the string "true", it could be rendered as a string or it could be rendered as a check box that is checked.nullis a valid valueisSelected- true if the cell is to be rendered with the selection highlighted; false otherwisehasFocus- if true, render cell appropriately. For example, put a special border on the cell, if the cell can be edited, render in the color used to indicate editingrow- the row index of the cell being drawn. When drawing the header, the value ofrowis -1column- the column index of the cell being drawn
-