Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
javax.swing.tree.DefaultTreeCellEditor
public class DefaultTreeCellEditor
extends Object
implements ActionListener, TreeCellEditor, TreeSelectionListener
Nested Class Summary | |
class |
|
class |
|
Field Summary | |
protected Color |
|
protected boolean |
|
protected Component |
|
protected Container |
|
protected Icon |
|
protected Font |
|
protected TreePath |
|
protected int |
|
protected int |
|
protected TreeCellEditor |
|
protected DefaultTreeCellRenderer |
|
protected Timer |
|
protected JTree |
|
Constructor Summary | |
| |
|
Method Summary | |
void |
|
void |
|
protected boolean |
|
void |
|
protected Container |
|
protected TreeCellEditor |
|
protected void |
|
Color |
|
CellEditorListener[] |
|
Object |
|
Font |
|
Component |
|
protected boolean |
|
boolean |
|
protected void |
|
void |
|
void |
|
void | |
protected void | |
boolean |
|
protected boolean |
|
protected void |
|
boolean |
|
void |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
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. If you wish to provide similar behavior you should directly override isCellEditable.
protected Component editingComponent
Component used in editing, obtained from the editingContainer.
protected Container editingContainer
Editing container, will contain the editorComponent.
public DefaultTreeCellEditor(JTree tree, DefaultTreeCellRenderer renderer)
Constructs a DefaultTreeCellEditor object for a JTree using the specified renderer and a default editor. (Use this constructor for normal editing.)
- Parameters:
tree
- - a JTree objectrenderer
- - a DefaultTreeCellRenderer object
public DefaultTreeCellEditor(JTree tree, DefaultTreeCellRenderer renderer, TreeCellEditor editor)
Constructs a DefaultTreeCellEditor object for a JTree using the specified renderer and the specified editor. (Use this constructor for specialized editing.)
- Parameters:
tree
- - a JTree objectrenderer
- - a DefaultTreeCellRenderer objecteditor
- - a TreeCellEditor object
public void actionPerformed(ActionEvent e)
Messaged when the timer fires.
- Specified by:
- actionPerformed in interface ActionListener
- Parameters:
e
- the event that characterizes the action.
public void addCellEditorListener(CellEditorListener listener)
Adds aCellEditorListener
object to this editor.
- Specified by:
- addCellEditorListener in interface CellEditor
- Parameters:
listener
- the listener to add
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.
- 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
public void cancelCellEditing()
Messages cancelCellEditing to the realEditor and removes it from this instance.
- Specified by:
- cancelCellEditing in interface CellEditor
protected Container createContainer()
Creates the container to manage placement of editingComponent.
- Returns:
- the container to manage the placement of the editingComponent.
protected TreeCellEditor createTreeCellEditor()
This is invoked if a TreeCellEditor is not supplied in the constructor. It returns a TextField editor.
- Returns:
- a new TextField editor
protected void determineOffset(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row)
determineOffset
- Parameters:
tree
- -value
- -isSelected
- -expanded
- -leaf
- -row
- -
public Color getBorderSelectionColor()
Returns the color the border is drawn.
- Returns:
- Color
public CellEditorListener[] getCellEditorListeners()
Returns all addedCellEditorListener
objects to this editor.
- Returns:
- an array of listeners
- Since:
- 1.4
public Object getCellEditorValue()
Returns the value currently being edited (requests it from therealEditor
.
- Specified by:
- getCellEditorValue in interface CellEditor
- Returns:
- the value currently being edited
public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row)
Configures the editor. Passed onto the realEditor. 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
- Parameters:
tree
- - the JTree that is asking the editor to edit; this parameter can be nullvalue
- - the value of the cell to be editedisSelected
- - true is the cell is to be rendered with selection highlightingexpanded
- - true if the node is expandedleaf
- - true if the node is a leaf noderow
- - the row index of the node being edited
- Returns:
- the component for editing
protected boolean inHitRegion(int x, int y)
Returns true if the passed in location is a valid mouse location to start editing from. This is implemented to return false if x is less than or equal to the width of the icon and icon gap displayed by the renderer. In other words this returns true if the user clicks over the text part displayed by the renderer, and false otherwise.
- Parameters:
x
- - the x-coordinate of the pointy
- - the y-coordinate of the point
- Returns:
- true if the passed in location is a valid mouse location
public boolean isCellEditable(EventObject event)
If the realEditor returns true to this message, prepareForEditing is messaged and true is returned.
- Specified by:
- isCellEditable in interface CellEditor
- Parameters:
event
- - the event the editor should use to consider whether to begin editing or not
- Returns:
- true if editing can be started
protected void prepareForEditing()
Invoked just before editing is to start. Will add the editingComponent to the editingContainer.
public void removeCellEditorListener(CellEditorListener listener)
Removes aCellEditorListener
object.
- Specified by:
- removeCellEditorListener in interface CellEditor
- Parameters:
listener
- the listener to remove
public void setBorderSelectionColor(Color newColor)
Sets the color to use for the border.
- Parameters:
newColor
- - the new border color
public void setFont(Font font)
Sets the font to edit with. null indicates the renderers font should be used. This will NOT override any font you have set in the editor the receiver was instantied with. If null for an editor was passed in, a default editor will be created that will pick up this font.
- Parameters:
font
- - the editing Font
protected void setTree(JTree newTree)
Sets the tree currently editing for. This is needed to add a selection listener.
- Parameters:
newTree
- - the new tree to be edited
public boolean shouldSelectCell(EventObject event)
Messages the realEditor for the return value.
- Specified by:
- shouldSelectCell in interface CellEditor
- 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
protected boolean shouldStartEditingTimer(EventObject event)
Returns true if event is a MouseEvent and the click count is 1.
- Parameters:
event
- - the event being studied
- Returns:
- true if editing should start
public boolean stopCellEditing()
If the realEditor will allow editing to stop, the realEditor is removed and true is returned, otherwise false is returned.
- Specified by:
- stopCellEditing in interface CellEditor
- Returns:
- true if editing was stopped; false otherwise
public void valueChanged(TreeSelectionEvent e)
Resets lastPath.
- Specified by:
- valueChanged in interface TreeSelectionListener
- Parameters:
e
- - the event that characterizes the change.