JavaTM 2 Platform
Std. Ed. v1.3.1

javax.swing
Class DefaultCellEditor

java.lang.Object
  |
  +--javax.swing.AbstractCellEditor
        |
        +--javax.swing.DefaultCellEditor
All Implemented Interfaces:
CellEditor, Serializable, TableCellEditor, TreeCellEditor

public class DefaultCellEditor
extends AbstractCellEditor
implements TableCellEditor, TreeCellEditor

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  int clickCountToStart
           
protected  DefaultCellEditor.EditorDelegate delegate
           
protected  JComponent editorComponent
           
 
Fields inherited from class javax.swing.AbstractCellEditor
changeEvent, listenerList
 
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 cancelCellEditing()
          Tell the editor to cancel editing and not accept any partially edited value.
 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 setClickCountToStart(int count)
          Specifies the number of clicks needed to start editing.
 boolean shouldSelectCell(EventObject anEvent)
          The return value of shouldSelectCell() is a boolean indicating whether the editing cell should be selected or not.
 boolean stopCellEditing()
          Tell the editor to stop editing and accept any partially edited value as the value of the editor.
 
Methods inherited from class javax.swing.AbstractCellEditor
addCellEditorListener, fireEditingCanceled, fireEditingStopped, removeCellEditorListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.CellEditor
addCellEditorListener, removeCellEditorListener
 

Field Detail

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
Specified by:
getCellEditorValue in interface CellEditor

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.
Specified by:
isCellEditable in interface CellEditor
Overrides:
isCellEditable in class AbstractCellEditor
Following copied from interface: javax.swing.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
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.
Specified by:
shouldSelectCell in interface CellEditor
Overrides:
shouldSelectCell in class AbstractCellEditor
Following copied from interface: javax.swing.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.
Specified by:
stopCellEditing in interface CellEditor
Overrides:
stopCellEditing in class AbstractCellEditor
Following copied from interface: javax.swing.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.
Specified by:
cancelCellEditing in interface CellEditor
Overrides:
cancelCellEditing in class AbstractCellEditor

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
Following copied from interface: javax.swing.tree.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
Following copied from interface: javax.swing.table.TableCellEditor
Parameters:
table - the JTable that is asking the editor to edit; 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. For example, 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 if the cell is to be rendered with 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
Std. Ed. v1.3.1

Submit a bug or feature
For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

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



Spec-Zone.ru - all specs in one place



free hit counter