javax.swing.tree
Class DefaultTreeCellEditor
- ActionListener, CellEditor, EventListener, TreeCellEditor, TreeSelectionListener
Participates in the tree cell editing.
void | actionPerformed(ActionEvent e) - Messaged when the timer fires.
|
void | addCellEditorListener(CellEditorListener listener) - Adds a
CellEditorListener object to this editor.
|
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.
|
void | cancelCellEditing() - Messages cancelCellEditing to the realEditor and removes it
from this instance.
|
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
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.
|
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
canEdit
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.
font
protected Font font
Font to paint with, null indicates font of renderer is to be used.
lastRow
protected int lastRow
Row that was last passed into getTreeCellEditorComponent.
offset
protected int offset
Used in editing. Indicates x position to place editingComponent.
timer
protected Timer timer
Used before starting the editing session.
tree
protected JTree tree
JTree instance listening too.
DefaultTreeCellEditor
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.)
tree
- - a JTree objectrenderer
- - a DefaultTreeCellRenderer object
DefaultTreeCellEditor
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.)
tree
- - a JTree objectrenderer
- - a DefaultTreeCellRenderer objecteditor
- - a TreeCellEditor object
canEditImmediately
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.
event
- - the event being studied
- true if event is null, or it is a MouseEvent with
a click count > 2 and inHitRegion returns true
createContainer
protected Container createContainer()
Creates the container to manage placement of editingComponent.
- the container to manage the placement of the editingComponent.
createTreeCellEditor
protected TreeCellEditor createTreeCellEditor()
This is invoked if a TreeCellEditor is not supplied in the constructor.
It returns a TextField editor.
determineOffset
protected void determineOffset(JTree tree,
Object value,
boolean isSelected,
boolean expanded,
boolean leaf,
int row)
determineOffset
tree
- -value
- -isSelected
- -expanded
- -leaf
- -row
- -
getFont
public Font getFont()
Gets the font used for editing.
getTreeCellEditorComponent
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.
- getTreeCellEditorComponent in interface TreeCellEditor
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
- the component for editing
inHitRegion
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.
x
- - the x-coordinate of the pointy
- - the y-coordinate of the point
- true if the passed in location is a valid mouse location
isCellEditable
public boolean isCellEditable(EventObject event)
If the realEditor returns true to this message, prepareForEditing
is messaged and true is returned.
- isCellEditable in interface CellEditor
event
- - the event the editor should use to consider whether to
begin editing or not
- true if editing can be started
prepareForEditing
protected void prepareForEditing()
Invoked just before editing is to start. Will add the
editingComponent to the editingContainer.
setBorderSelectionColor
public void setBorderSelectionColor(Color newColor)
Sets the color to use for the border.
newColor
- - the new border color
setFont
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.
font
- - the editing Font
setTree
protected void setTree(JTree newTree)
Sets the tree currently editing for. This is needed to add a selection
listener.
newTree
- -
the new tree to be edited
shouldSelectCell
public boolean shouldSelectCell(EventObject event)
Messages the realEditor for the return value.
- shouldSelectCell in interface CellEditor
event
- -
the event the editor should use to start editing
- true if the editor would like the editing cell to be selected;
otherwise returns false
shouldStartEditingTimer
protected boolean shouldStartEditingTimer(EventObject event)
Returns true if event is a MouseEvent and the click count is 1.
event
- - the event being studied
- true if editing should start
startEditingTimer
protected void startEditingTimer()
Starts the editing timer (if one installed).
stopCellEditing
public boolean stopCellEditing()
If the realEditor will allow editing to stop, the realEditor
is removed and true is returned, otherwise false is returned.
- stopCellEditing in interface CellEditor
- true if editing was stopped; false otherwise
DefaultTreeCellEditor.java --
Copyright (C) 2002, 2004, 2005 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.