javax.swing.tree
public class DefaultTreeCellEditor extends Object implements ActionListener, TreeCellEditor, TreeSelectionListener
Nested Class Summary | |
---|---|
class | DefaultTreeCellEditor.DefaultTextField
The default text field, used in the editing sessions. |
class | DefaultTreeCellEditor.EditorContainer
This container that appears on the tree during editing session.
|
Field Summary | |
---|---|
protected Color | borderSelectionColor
True if the border selection color should be drawn. |
protected boolean | canEdit
As of Java 2 platform v1.4 this field should no longer be used.
|
protected Component | editingComponent
Component used in editing, obtained from the editingContainer. |
protected Container | editingContainer
Editing container, will contain the editorComponent. |
protected Icon | editingIcon
Icon to use when editing. |
protected Font | font
Font to paint with, null indicates font of renderer is to be used. |
protected TreePath | lastPath
Last path that was selected. |
protected int | lastRow
Row that was last passed into getTreeCellEditorComponent. |
protected int | offset
Used in editing. |
protected TreeCellEditor | realEditor
Editor handling the editing. |
protected DefaultTreeCellRenderer | renderer
Renderer, used to get border and offsets from. |
protected Timer | timer
Used before starting the editing session. |
protected JTree | tree
JTree instance listening too. |
Constructor Summary | |
---|---|
DefaultTreeCellEditor(JTree tree, DefaultTreeCellRenderer renderer)
Constructs a DefaultTreeCellEditor object for a JTree using the
specified renderer and a default editor. | |
DefaultTreeCellEditor(JTree tree, DefaultTreeCellRenderer renderer, TreeCellEditor editor)
Constructs a DefaultTreeCellEditor object for a JTree using the specified
renderer and the specified editor. |
Method Summary | |
---|---|
void | actionPerformed(ActionEvent e)
Messaged when the timer fires.
|
void | addCellEditorListener(CellEditorListener listener)
Adds a CellEditorListener object to this editor.
|
void | cancelCellEditing()
Messages cancelCellEditing to the realEditor and removes it
from this instance. |
protected boolean | canEditImmediately(EventObject event)
Returns true if event is null, or it is a MouseEvent with
a click count > 2 and inHitRegion returns true.
|
protected Container | createContainer()
Creates the container to manage placement of editingComponent.
|
protected TreeCellEditor | createTreeCellEditor()
This is invoked if a TreeCellEditor is not supplied in the constructor.
|
protected void | determineOffset(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row)
determineOffset |
Color | getBorderSelectionColor()
Returns the color the border is drawn. |
CellEditorListener[] | getCellEditorListeners()
Returns all added CellEditorListener objects to this editor.
|
Object | getCellEditorValue()
Returns the value currently being edited (requests it from the
{@link #realEditor}.
|
Font | getFont()
Gets the font used for editing.
|
Component | getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row)
Configures the editor. |
protected boolean | inHitRegion(int x, int y)
Returns true if the passed in location is a valid mouse location
to start editing from. |
boolean | isCellEditable(EventObject event)
If the realEditor returns true to this message, prepareForEditing
is messaged and true is returned.
|
protected void | prepareForEditing()
Invoked just before editing is to start. |
void | removeCellEditorListener(CellEditorListener listener)
Removes a CellEditorListener object.
|
void | setBorderSelectionColor(Color newColor)
Sets the color to use for the border. |
void | setFont(Font font)
Sets the font to edit with. null indicates the renderers
font should be used. |
protected void | setTree(JTree newTree)
Sets the tree currently editing for. |
boolean | shouldSelectCell(EventObject event)
Messages the realEditor for the return value.
|
protected boolean | shouldStartEditingTimer(EventObject event)
Returns true if event is a MouseEvent and the click count is 1.
|
protected void | startEditingTimer()
Starts the editing timer (if one installed). |
boolean | stopCellEditing()
If the realEditor will allow editing to stop, the realEditor
is removed and true is returned, otherwise false is returned. |
void | valueChanged(TreeSelectionEvent e)
Resets lastPath.
|
Parameters: tree - a JTree object renderer - a DefaultTreeCellRenderer object
Parameters: tree - a JTree object renderer - a DefaultTreeCellRenderer object editor - a TreeCellEditor object
Parameters: e the event that characterizes the action.
CellEditorListener
object to this editor.
Parameters: listener the listener to add
Parameters: event - the event being studied
Returns: true if event is null, or it is a MouseEvent with a click count > 2 and inHitRegion returns true
Returns: the container to manage the placement of the editingComponent.
Returns: a new TextField editor
Parameters: tree - value - isSelected - expanded - leaf - row -
Returns: Color
CellEditorListener
objects to this editor.
Returns: an array of listeners
Since: 1.4
Returns: the value currently being edited
Returns: the editing font
Parameters: tree - 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 rendered 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
Parameters: x - the x-coordinate of the point y - the y-coordinate of the point
Returns: true if the passed in location is a valid mouse location
Parameters: event - the event the editor should use to consider whether to begin editing or not
Returns: true if editing can be started
CellEditorListener
object.
Parameters: listener the listener to remove
Parameters: newColor - the new border color
Parameters: font - the editing Font
Parameters: newTree - the new tree to be edited
Parameters: event - the event the editor should use to start editing
Returns: true if the editor would like the editing cell to be selected; otherwise returns false
Parameters: event - the event being studied
Returns: true if editing should start
Returns: true if editing was stopped; false otherwise
Parameters: e - the event that characterizes the change.