Groovy Documentation

com.wordpress.tipsforjava.swing.table
[Java] Class ComboBoxTableEditor

java.lang.Object
  javax.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.

Authors:
Rob Camick
Darryl Burke


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 DefaultCellEditor
getComponent, isCellEditable, stopCellEditing, cancelCellEditing, getCellEditorValue, getTableCellEditorComponent, shouldSelectCell, setClickCountToStart, getClickCountToStart, getTreeCellEditorComponent, addCellEditorListener, removeCellEditorListener, getCellEditorListeners, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 
Methods inherited from class AbstractCellEditor
isCellEditable, stopCellEditing, addCellEditorListener, cancelCellEditing, removeCellEditorListener, shouldSelectCell, getCellEditorListeners, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll, getCellEditorValue
 

Field Detail

models

protected HashMap models


relatedColumn

private int relatedColumn


 
Constructor Detail

ComboBoxTableEditor

public ComboBoxTableEditor()
Create a combo box editor that supports different combo box models. Convenience constructor. The related column is assumed to be the column to the left of the editing column.


ComboBoxTableEditor

public ComboBoxTableEditor(int relatedColumn)
Create a combo box editor that supports different combo box models.
Parameters:
relatedColumn - column whose value will be used to lookup the model to be used by the combo box


ComboBoxTableEditor

public ComboBoxTableEditor(JComboBox comboBox, int relatedColumn)
Create a combo box editor that supports different combo box models.
Parameters:
comboBox - a JComboBox to be used as the editor
relatedColumn - column whose value will be used to lookup the model to be used by the combo box


 
Method Detail

addModel

public 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.
Parameters:
key - used to lookup the related model
items - List containing items to create a DefaultComboBoxModel


addModel

public 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.
Parameters:
key - used to lookup the related model
items - Vector containing items to create a DefaultComboBoxModel


addModel

public 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.
Parameters:
key - used to lookup the related model
items - Array containing items to create a DefaultComboBoxModel


addModel

public 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.
Parameters:
key - used to lookup the related model
model - model to be used by the editor for the given key


getModelForRow

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.


getTableCellEditorComponent

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