Spec-Zone .ru
спецификации, руководства, описания, API
JavaTM 2 Platform
Standard Edition

javax.swing
Class DefaultCellEditor

java.lang.Object
  |
  +--javax.swing.DefaultCellEditor

public class DefaultCellEditor
extends Object
implements TableCellEditor, TreeCellEditor, Serializable

The default editor for table and tree cells.

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.

See Also:
Serialized Form

Inner Class Summary
protected  class DefaultCellEditor.EditorDelegate
           
 
Field Summary
protected  ChangeEvent changeEvent
           
protected  int clickCountToStart
           
protected  DefaultCellEditor.EditorDelegate delegate
           
protected  JComponent editorComponent
           
protected  EventListenerList listenerList
          Event listeners
 
Constructor Summary
DefaultCellEditor(JCheckBox checkBox)
          Constructs a DefaultCellEditor object that uses a check box.
DefaultCellEditor(JComboBox comboBox)
          Constructs a DefaultCellEditor object that uses a combo box.
DefaultCellEditor(JTextField textField)
          Constructs a DefaultCellEditor that uses a text field.
 
Method Summary
 void addCellEditorListener(CellEditorListener l)
          Add a listener to the list that's notified when the editor starts, stops, or cancels editing.
 void cancelCellEditing()
          Tell the editor to cancel editing and not accept any partially edited value.
protected  void fireEditingCanceled()
           
protected  void fireEditingStopped()
           
 Object getCellEditorValue()
          Returns the value contained in the editor
 int getClickCountToStart()
          ClickCountToStart controls the number of clicks required to start editing.
 Component getComponent()
          Returns the a reference to the editor component.
 Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
          Sets an initial value for the editor.
 Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row)
          Sets an initial value for the editor.
 boolean isCellEditable(EventObject anEvent)
          Ask the editor if it can start editing using anEvent.
 void removeCellEditorListener(CellEditorListener l)
          Remove a listener from the list that's notified
 void setClickCountToStart(int count)
          Specifies the number of clicks needed to start editing.
 boolean shouldSelectCell(EventObject anEvent)
          Tell the editor to start editing using anEvent.
 boolean stopCellEditing()
          Tell the editor to stop editing and accept any partially edited value as the value of the editor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listenerList

protected EventListenerList listenerList
Event listeners

changeEvent

protected transient ChangeEvent changeEvent

editorComponent

protected JComponent editorComponent

delegate

protected DefaultCellEditor.EditorDelegate delegate

clickCountToStart

protected int clickCountToStart
Constructor Detail

DefaultCellEditor

public DefaultCellEditor(JTextField textField)
Constructs a DefaultCellEditor that uses a text field.
Parameters:
x - a JTextField object ...

DefaultCellEditor

public DefaultCellEditor(JCheckBox checkBox)
Constructs a DefaultCellEditor object that uses a check box.
Parameters:
x - a JCheckBox object ...

DefaultCellEditor

public DefaultCellEditor(JComboBox comboBox)
Constructs a DefaultCellEditor object that uses a combo box.
Parameters:
x - a JComboBox object ...
Method Detail

getComponent

public Component getComponent()
Returns the a reference to the editor component.
Returns:
the editor Component

setClickCountToStart

public void setClickCountToStart(int count)
Specifies the number of clicks needed to start editing.
Parameters:
count - an int specifying the number of clicks needed to start editing
See Also:
getClickCountToStart()

getClickCountToStart

public int getClickCountToStart()
ClickCountToStart controls the number of clicks required to start editing.

getCellEditorValue

public Object getCellEditorValue()
Description copied from interface: CellEditor
Returns the value contained in the editor

isCellEditable

public boolean isCellEditable(EventObject anEvent)
Description copied from interface: CellEditor
Ask the editor if it can start editing using anEvent. anEvent is in the invoking component coordinate system. The editor can not assume the Component returned by getCellEditorComponent() is installed. This method is intended for the use of client to avoid the cost of setting up and installing the editor component if editing is not possible. If editing can be started this method returns true.
Tags copied from interface: CellEditor
Parameters:
anEvent - the event the editor should use to consider whether to begin editing or not.
Returns:
true if editing can be started.
See Also:
CellEditor.shouldSelectCell(java.util.EventObject)

shouldSelectCell

public boolean shouldSelectCell(EventObject anEvent)
Description copied from interface: CellEditor
Tell the editor to start editing using anEvent. It is up to the editor if it want to start editing in different states depending on the exact type of anEvent. For example, with a text field editor, if the event is a mouse event the editor might start editing with the cursor at the clicked point. If the event is a keyboard event, it might want replace the value of the text field with that first key, etc. anEvent is in the invoking component's coordinate system. A null value is a valid parameter for anEvent, and it is up to the editor to determine what is the default starting state. For example, a text field editor might want to select all the text and start editing if anEvent is null. The editor can assume the Component returned by getCellEditorComponent() is properly installed in the clients Component hierarchy before this method is called.

The return value of shouldSelectCell() is a boolean indicating whether the editing cell should be selected or not. Typically, the return value is true, because is most cases the editing cell should be selected. However, it is useful to return false to keep the selection from changing for some types of edits. eg. A table that contains a column of check boxes, the user might want to be able to change those checkboxes without altering the selection. (See Netscape Communicator for just such an example) Of course, it is up to the client of the editor to use the return value, but it doesn't need to if it doesn't want to.

Tags copied from interface: CellEditor
Parameters:
anEvent - the event the editor should use to start editing.
Returns:
true if the editor would like the editing cell to be selected
See Also:
CellEditor.isCellEditable(java.util.EventObject)

stopCellEditing

public boolean stopCellEditing()
Description copied from interface: CellEditor
Tell the editor to stop editing and accept any partially edited value as the value of the editor. The editor returns false if editing was not stopped, useful for editors which validates and can not accept invalid entries.
Tags copied from interface: CellEditor
Returns:
true if editing was stopped

cancelCellEditing

public void cancelCellEditing()
Description copied from interface: CellEditor
Tell the editor to cancel editing and not accept any partially edited value.

addCellEditorListener

public void addCellEditorListener(CellEditorListener l)
Description copied from interface: CellEditor
Add a listener to the list that's notified when the editor starts, stops, or cancels editing.
Tags copied from interface: CellEditor
Parameters:
l - the CellEditorListener

removeCellEditorListener

public void removeCellEditorListener(CellEditorListener l)
Description copied from interface: CellEditor
Remove a listener from the list that's notified
Tags copied from interface: CellEditor
Parameters:
l - the CellEditorListener

fireEditingStopped

protected void fireEditingStopped()

fireEditingCanceled

protected void fireEditingCanceled()

getTreeCellEditorComponent

public Component getTreeCellEditorComponent(JTree tree,
                                            Object value,
                                            boolean isSelected,
                                            boolean expanded,
                                            boolean leaf,
                                            int row)
Description copied from interface: TreeCellEditor
Sets an initial value for the editor. This will cause the editor to stopEditing and lose any partially edited value if the editor is editing when this method is called.

Returns the component that should be added to the client's Component hierarchy. Once installed in the client's hierarchy this component will then be able to draw and receive user input.

Specified by:
getTreeCellEditorComponent in interface TreeCellEditor
Tags copied from interface: TreeCellEditor
Parameters:
table - the JTree that is asking the editor to edit This parameter can be null.
value - the value of the cell to be edited.
isSelected - true is the cell is to be renderer with selection highlighting
expanded - true if the node is expanded
leaf - true if the node is a leaf node
row - the row index of the node being edited
Returns:
the component for editing

getTableCellEditorComponent

public Component getTableCellEditorComponent(JTable table,
                                             Object value,
                                             boolean isSelected,
                                             int row,
                                             int column)
Description copied from interface: TableCellEditor
Sets an initial value for the editor. This will cause the editor to stopEditing and lose any partially edited value if the editor is editing when this method is called.

Returns the component that should be added to the client's Component hierarchy. Once installed in the client's hierarchy this component will then be able to draw and receive user input.

Specified by:
getTableCellEditorComponent in interface TableCellEditor
Tags copied from interface: TableCellEditor
Parameters:
table - the JTable that is asking the editor to edit This parameter can be null.
value - the value of the cell to be edited. It is up to the specific editor to interpret and draw the value. eg. if value is the String "true", it could be rendered as a string or it could be rendered as a check box that is checked. null is a valid value.
isSelected - true is the cell is to be renderer with selection highlighting
row - the row of the cell being edited
column - the column of the cell being edited
Returns:
the component for editing

JavaTM 2 Platform
Standard Edition

Submit a bug or feature
Java, Java 2D, and JDBC are a trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1999 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.