Package org.jdesktop.swingx.autocomplete
Class ComboBoxCellEditor
- java.lang.Object
-
- javax.swing.AbstractCellEditor
-
- org.jdesktop.swingx.autocomplete.ComboBoxCellEditor
-
- All Implemented Interfaces:
java.io.Serializable
,javax.swing.CellEditor
,javax.swing.table.TableCellEditor
public class ComboBoxCellEditor extends javax.swing.AbstractCellEditor implements javax.swing.table.TableCellEditor, java.io.Serializable
This is a cell editor that can be used when a combo box (that has been set up for automatic completion) is to be used in a JTable. The
DefaultCellEditor
won't work in this case, because each time an item gets selected it stops cell editing and hides the combo box.Usage example:
JTable table = ...; JComboBox comboBox = ...; ... TableColumn column = table.getColumnModel().getColumn(0); column.setCellEditor(new ComboBoxCellEditor(comboBox));
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ComboBoxCellEditor(javax.swing.JComboBox comboBox)
Creates a new ComboBoxCellEditor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
getCellEditorValue()
Returns the value contained in the combo boxjava.awt.Component
getTableCellEditorComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, int row, int column)
Sets an initial value for the combo box.boolean
stopCellEditing()
Tells the combo box to stop editing and accept any partially edited value as the value of the combo box.-
Methods inherited from class javax.swing.AbstractCellEditor
addCellEditorListener, cancelCellEditing, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, isCellEditable, removeCellEditorListener, shouldSelectCell
-
-
-
-
Method Detail
-
getCellEditorValue
public java.lang.Object getCellEditorValue()
Returns the value contained in the combo box- Specified by:
getCellEditorValue
in interfacejavax.swing.CellEditor
- Returns:
- the value contained in the combo box
-
stopCellEditing
public boolean stopCellEditing()
Tells the combo box to stop editing and accept any partially edited value as the value of the combo box. Always returns true.- Specified by:
stopCellEditing
in interfacejavax.swing.CellEditor
- Overrides:
stopCellEditing
in classjavax.swing.AbstractCellEditor
- Returns:
- true
-
getTableCellEditorComponent
public java.awt.Component getTableCellEditorComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, int row, int column)
Sets an initial value for the combo box. Returns the combo box that should be added to the client's Component hierarchy. Once installed in the client's hierarchy this combo box will then be able to draw and receive user input.- Specified by:
getTableCellEditorComponent
in interfacejavax.swing.table.TableCellEditor
- Parameters:
table
- the JTable that is asking the editor to edit; can be nullvalue
- the value of the cell to be edited; null is a valid valueisSelected
- will be ignoredrow
- the row of the cell being editedcolumn
- the column of the cell being edited- Returns:
- the combo box for editing
-
-