|
Groovy Documentation | |||||||
| FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjavax.swing.AbstractCellEditor
javax.swing.DefaultCellEditor
com.wordpress.tipsforjava.swing.table.ComboBoxTableEditor
public class ComboBoxTableEditor extends DefaultCellEditor
This class will use a combo box as the editor for a JTable cell. It is different from the default combo box editor in that it supports multiple combo box models. The appropriate model will be choosen based on the cell about to be edited. The model to be used by the combo box is determined by the value contained in the cell of a related column. This value is used to lookup the model.
| Field Summary | |
|---|---|
protected HashMap |
models
|
private int |
relatedColumn
|
| Constructor Summary | |
ComboBoxTableEditor()
Create a combo box editor that supports different combo box models. |
|
ComboBoxTableEditor(int relatedColumn)
Create a combo box editor that supports different combo box models. |
|
ComboBoxTableEditor(JComboBox comboBox, int relatedColumn)
Create a combo box editor that supports different combo box models. |
|
| Method Summary | |
|---|---|
void
|
addModel(Object key, List items)
Convenience method to create a ComboBoxModel to be used by the editor when the related column contains the specified key. |
void
|
addModel(Object key, Vector items)
Convenience method to create a ComboBoxModel to be used by the editor when the related column contains the specified key. |
void
|
addModel(Object key, Object[] items)
Convenience method to create a ComboBoxModel to be used by the editor when the related column contains the specified key. |
void
|
addModel(Object key, ComboBoxModel model)
Convenience method to create a ComboBoxModel to be used by the editor when the related column contains the specified key. |
protected ComboBoxModel
|
getModelForRow(JTable table, Object value, int row, int column)
Each time the editor is invoked the combo box model will be set based on the value contained in the related cell. |
Component
|
getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
|
| Methods inherited from class AbstractCellEditor | |
|---|---|
| isCellEditable, stopCellEditing, addCellEditorListener, cancelCellEditing, removeCellEditorListener, shouldSelectCell, getCellEditorListeners, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll, getCellEditorValue |
| Field Detail |
|---|
protected HashMap models
private int relatedColumn
| Constructor Detail |
|---|
public ComboBoxTableEditor()
public ComboBoxTableEditor(int relatedColumn)
relatedColumn - column whose value will be used to lookup the
model to be used by the combo box
public ComboBoxTableEditor(JComboBox comboBox, int relatedColumn)
comboBox - a JComboBox to be used as the editorrelatedColumn - column whose value will be used to lookup the
model to be used by the combo box
| Method Detail |
|---|
public void addModel(Object key, List items)
key - used to lookup the related modelitems - List containing items to create a DefaultComboBoxModel
public void addModel(Object key, Vector items)
key - used to lookup the related modelitems - Vector containing items to create a DefaultComboBoxModel
public void addModel(Object key, Object[] items)
key - used to lookup the related modelitems - Array containing items to create a DefaultComboBoxModel
public void addModel(Object key, ComboBoxModel model)
key - used to lookup the related modelmodel - model to be used by the editor for the given key
protected ComboBoxModel getModelForRow(JTable table, Object value, int row, int column)
de /** * Each time the editor is invoked the combo box model will be set * based on the value contained in the related cell. */ public public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
Groovy Documentation