javax.swing

Class DefaultCellEditor.EditorDelegate

protected class DefaultCellEditor.EditorDelegate extends Object implements ActionListener, ItemListener, Serializable

This changeable module access the editor component in the component specific way. For instance, to set the value for JTextField, we need to call setText(String), and for JCheckBox we need to call setSelected(boolean). Each default editor has the component specific derivative of this class. These derivatives are private inner classes of the DefaultCellEditor. The editor delegate is also set for the editor component as the action listener. It listens for the events that indicate that editing has stopped.
Field Summary
protected Objectvalue
The object value (updated when getting and setting the value).
Constructor Summary
protected EditorDelegate()
Constructor EditorDelegate
Method Summary
voidactionPerformed(ActionEvent event)
This event is fired by the editor component (for instance, by pressing ENTER in the {@link JTextField}.
voidcancelCellEditing()
Cancel the cell editing session.
ObjectgetCellEditorValue()
Get the value for the editor component.
booleanisCellEditable(EventObject event)
The default method returns true for the {@link MouseEvent} and false for any other events.
voiditemStateChanged(ItemEvent event)
This event is fired by the editor component.The default method delegates call to the {@link #stopCellEditing}, finishing the editing session.
voidsetValue(Object aValue)
Set the value for the editor component.
booleanshouldSelectCell(EventObject event)
Returns true to indicate that the editing cell can be selected.
booleanstartCellEditing(EventObject event)
Start editing session and returns true to indicate the editing has begun.
booleanstopCellEditing()
Finish the cell editing session.

Field Detail

value

protected Object value
The object value (updated when getting and setting the value).

Constructor Detail

EditorDelegate

protected EditorDelegate()
Constructor EditorDelegate

Method Detail

actionPerformed

public void actionPerformed(ActionEvent event)
This event is fired by the editor component (for instance, by pressing ENTER in the {@link JTextField}. The default method delegates call to the {@link #stopCellEditing}, finishing the editing session.

Parameters: event unused in default method

cancelCellEditing

public void cancelCellEditing()
Cancel the cell editing session. This method notifies the registered cell editor listeners (including the table) that the editing has been canceled.

getCellEditorValue

public Object getCellEditorValue()
Get the value for the editor component. This method is normally overridden to obtain the value in the way, specific for the text component, check box or combo box.

Returns: value the value of the component (String, Boolean or Number).

isCellEditable

public boolean isCellEditable(EventObject event)
The default method returns true for the {@link MouseEvent} and false for any other events.

Parameters: event the event to check

Returns: true if the passed event is the mouse event and false otherwise.

itemStateChanged

public void itemStateChanged(ItemEvent event)
This event is fired by the editor component.The default method delegates call to the {@link #stopCellEditing}, finishing the editing session.

Parameters: event unused in default method

setValue

public void setValue(Object aValue)
Set the value for the editor component. This method is normally overridden to set the value in the way, specific for the text component, check box or combo box.

Parameters: aValue the value to set (String, Boolean or Number).

shouldSelectCell

public boolean shouldSelectCell(EventObject event)
Returns true to indicate that the editing cell can be selected. The default method returns true without action but may be overridden in derived classes for more specific behavior.

Parameters: event unused in default method

Returns: true always

startCellEditing

public boolean startCellEditing(EventObject event)
Start editing session and returns true to indicate the editing has begun. The default method returns true without action but may be overridden in derived classes for more specific behavior.

Parameters: event the event.

Returns: true, always

stopCellEditing

public boolean stopCellEditing()
Finish the cell editing session. This method notifies the registered cell editor listeners (including the table) that the editing has been stopped.

Returns: boolean