javax.swing

Class DefaultCellEditor.EditorDelegate

Enclosing Class:
DefaultCellEditor
Implemented Interfaces:
ActionListener, EventListener, ItemListener, Serializable

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.
See Also:
Serialized Form

Field Summary

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

Constructor Summary

EditorDelegate()
Constructor EditorDelegate

Method Summary

void
actionPerformed(ActionEvent event)
This event is fired by the editor component (for instance, by pressing ENTER in the JTextField.
void
cancelCellEditing()
Cancel the cell editing session.
Object
getCellEditorValue()
Get the value for the editor component.
boolean
isCellEditable(EventObject event)
The default method returns true for the MouseEvent and false for any other events.
void
itemStateChanged(ItemEvent event)
This event is fired by the editor component.The default method delegates call to the stopCellEditing(), finishing the editing session.
void
setValue(Object aValue)
Set the value for the editor component.
boolean
shouldSelectCell(EventObject event)
Returns true to indicate that the editing cell can be selected.
boolean
startCellEditing(EventObject event)
Start editing session and returns true to indicate the editing has begun.
boolean
stopCellEditing()
Finish the cell editing session.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

value

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

Constructor Details

EditorDelegate

protected EditorDelegate()
Constructor EditorDelegate

Method Details

actionPerformed

public void actionPerformed(ActionEvent event)
This event is fired by the editor component (for instance, by pressing ENTER in the JTextField. The default method delegates call to the stopCellEditing(), finishing the editing session.
Specified by:
actionPerformed in interface ActionListener
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 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 stopCellEditing(), finishing the editing session.
Specified by:
itemStateChanged in interface ItemListener
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

DefaultCellEditor.java -- Copyright (C) 2002, 2004, 2006, Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.