TreeCellEditor. You need to supply an
instance of DefaultTreeCellRenderer
so that the icons can be obtained. You can optionally supply
a TreeCellEditor that will be laid out according
to the icon in the DefaultTreeCellRenderer.
If you do not supply a TreeCellEditor,
a TextField will be used. Editing is started
on a triple mouse click, or after a click, pause, click and
a delay of 1200 milliseconds.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. As of 1.4, support for long term storage
of all JavaBeans
has been added to the java.beans package.
Please see java..
javax.swing.JTree
| Modifier and Type | Class and Description |
|---|---|
| public class | DefaultTreeCellEditor.
|
| public class | DefaultTreeCellEditor.
Container responsible for placing the |
| Modifier and Type | Field and Description |
|---|---|
| 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 transient Component | editingComponent
Component used in editing, obtained from the
|
| protected Container | editingContainer
Editing container, will contain the |
| protected transient Icon | editingIcon
Icon to use when editing. |
| protected Font | font
Font to paint with, |
| protected transient TreePath | lastPath
Last path that was selected. |
| protected transient int | lastRow
Row that was last passed into
|
| protected transient int | offset
Used in editing. |
| protected TreeCellEditor | realEditor
Editor handling the editing. |
| protected DefaultTreeCellRenderer | renderer
Renderer, used to get border and offsets from. |
| protected transient Timer | timer
Used before starting the editing session. |
| protected transient JTree | tree
|
| Access | Constructor and Description |
|---|---|
| public | DefaultTreeCellEditor(JTree
a tree, DefaultTreeCellRenderer JTree objecta renderer)DefaultTreeCellRenderer objectConstructs a |
| public | DefaultTreeCellEditor(JTree
a tree, DefaultTreeCellRenderer JTree objecta renderer, TreeCellEditor DefaultTreeCellRenderer objecta editor)TreeCellEditor objectConstructs a |
| Modifier and Type | Method and Description |
|---|---|
| public void | actionPerformed(ActionEvent e)
Implements java. Messaged when the timer fires, this will start the editing session. |
| public void | addCellEditorListener(CellEditorListener
the listener to be added l)Implements javax. Adds the |
| public void | cancelCellEditing()
Implements javax. Messages |
| protected boolean | Returns: whether editing can be started for the giveneventthe event being studied event)Returns true if |
| private void | |
| protected Container | Returns: new Container objectCreates the container to manage placement of
|
| protected TreeCellEditor | Returns: a newTextField editorThis is invoked if a |
| protected void | determineOffset(JTree
a tree, Object JTree objecta value value, boolean selection status isSelected, boolean expansion status expanded, boolean leaf status leaf, int current row row)Determine the offset. |
| public Color | |
| public CellEditorListener[] | Returns: all of theCellEditorListeners added or an empty
array if no listeners have been addedReturns an array of all the |
| public Object | Returns: the value currently being editedImplements javax. Returns the value currently being edited. |
| public Font | |
| public Component | getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row)
Implements javax. Configures the editor. |
| protected boolean | Returns: true if the passed in location is a valid mouse locationthe x-coordinate of the point x, int the y-coordinate of the point y)Returns true if the passed in location is a valid mouse location to start editing from. |
| public boolean | isCellEditable(EventObject event)
Implements javax. If the |
| protected void | |
| public void | removeCellEditorListener(CellEditorListener
the listener to be removed l)Implements javax. Removes the previously added |
| public void | |
| public void | |
| protected void | |
| public boolean | shouldSelectCell(EventObject event)
Implements javax. Messages the |
| protected boolean | Returns: whetherevent should starts the editing timerthe event being studied event)Returns true if |
| protected void | |
| public boolean | stopCellEditing()
Implements javax. If the |
| public void | valueChanged(TreeSelectionEvent e)
Implements javax. Resets |
| borderSelectionColor | back to summary |
|---|---|
| protected Color borderSelectionColor True if the border selection color should be drawn. | |
| canEdit | back to summary |
|---|---|
| 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
| |
| editingComponent | back to summary |
|---|---|
| protected transient Component editingComponent Component used in editing, obtained from the
| |
| editingContainer | back to summary |
|---|---|
| protected Container editingContainer Editing container, will contain the | |
| editingIcon | back to summary |
|---|---|
| protected transient Icon editingIcon Icon to use when editing. | |
| font | back to summary |
|---|---|
| protected Font font Font to paint with, | |
| lastPath | back to summary |
|---|---|
| protected transient TreePath lastPath Last path that was selected. | |
| lastRow | back to summary |
|---|---|
| protected transient int lastRow Row that was last passed into
| |
| offset | back to summary |
|---|---|
| protected transient int offset Used in editing. Indicates x position to place
| |
| realEditor | back to summary |
|---|---|
| protected TreeCellEditor realEditor Editor handling the editing. | |
| renderer | back to summary |
|---|---|
| protected DefaultTreeCellRenderer renderer Renderer, used to get border and offsets from. | |
| timer | back to summary |
|---|---|
| protected transient Timer timer Used before starting the editing session. | |
| tree | back to summary |
|---|---|
| protected transient JTree tree
| |
| DefaultTreeCellEditor | back to summary |
|---|---|
| public DefaultTreeCellEditor(JTree tree, DefaultTreeCellRenderer renderer) Constructs a
| |
| DefaultTreeCellEditor | back to summary |
|---|---|
| public DefaultTreeCellEditor(JTree tree, DefaultTreeCellRenderer renderer, TreeCellEditor editor) Constructs a
| |
| actionPerformed | back to summary |
|---|---|
| public void actionPerformed(ActionEvent e) Implements java. Messaged when the timer fires, this will start the editing session. | |
| addCellEditorListener | back to summary |
|---|---|
| public void addCellEditorListener(CellEditorListener l) Implements javax. Adds the
| |
| cancelCellEditing | back to summary |
|---|---|
| public void cancelCellEditing() Implements javax. Messages | |
| canEditImmediately | back to summary |
|---|---|
| protected boolean canEditImmediately(EventObject event) Returns true if
| |
| cleanupAfterEditing | back to summary |
|---|---|
| private void cleanupAfterEditing() Cleans up any state after editing has completed. Removes the
| |
| createContainer | back to summary |
|---|---|
| protected Container createContainer() Creates the container to manage placement of
| |
| createTreeCellEditor | back to summary |
|---|---|
| protected TreeCellEditor createTreeCellEditor() This is invoked if a
| |
| determineOffset | back to summary |
|---|---|
| protected void determineOffset(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) Determine the offset. | |
| getBorderSelectionColor | back to summary |
|---|---|
| public Color getBorderSelectionColor() Returns the color the border is drawn.
| |
| getCellEditorListeners | back to summary |
|---|---|
| public CellEditorListener[] getCellEditorListeners() Returns an array of all the
| |
| getCellEditorValue | back to summary |
|---|---|
| public Object getCellEditorValue() Implements javax. Returns the value currently being edited.
| |
| getFont | back to summary |
|---|---|
| public Font getFont() Gets the font used for editing. | |
| getTreeCellEditorComponent | back to summary |
|---|---|
| public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) Implements javax. Configures the editor. Passed onto the | |
| inHitRegion | back to summary |
|---|---|
| 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
| |
| isCellEditable | back to summary |
|---|---|
| public boolean isCellEditable(EventObject event) Implements javax. If the | |
| prepareForEditing | back to summary |
|---|---|
| protected void prepareForEditing() Invoked just before editing is to start. Will add the
| |
| removeCellEditorListener | back to summary |
|---|---|
| public void removeCellEditorListener(CellEditorListener l) Implements javax. Removes the previously added
| |
| setBorderSelectionColor | back to summary |
|---|---|
| public void setBorderSelectionColor(Color newColor) Sets the color to use for the border.
| |
| setFont | back to summary |
|---|---|
| public void setFont(Font font) Sets the font to edit with. | |
| setTree | back to summary |
|---|---|
| protected void setTree(JTree newTree) Sets the tree currently editing for. This is needed to add a selection listener.
| |
| shouldSelectCell | back to summary |
|---|---|
| public boolean shouldSelectCell(EventObject event) Implements javax. Messages the | |
| shouldStartEditingTimer | back to summary |
|---|---|
| protected boolean shouldStartEditingTimer(EventObject event) Returns true if
| |
| startEditingTimer | back to summary |
|---|---|
| protected void startEditingTimer() Starts the editing timer. | |
| stopCellEditing | back to summary |
|---|---|
| public boolean stopCellEditing() Implements javax. If the | |
| valueChanged | back to summary |
|---|---|
| public void valueChanged(TreeSelectionEvent e) Implements javax. Resets | |
TextField used when no editor is supplied.
This textfield locks into the border it is constructed with.
It also prefers its parents font over its font. And if the
renderer is not null and no font
has been specified the preferred height is that of the renderer.
| Modifier and Type | Field and Description |
|---|---|
| protected Border | border
Border to use.
|
| Access | Constructor and Description |
|---|---|
| public | DefaultTextField(Border
a border)Border objectConstructs a
|
| Modifier and Type | Method and Description |
|---|---|
| public Border | getBorder()
Overrides javax. Overrides |
| public Font | getFont()
Overrides java. Implements java. Gets the font of this component. |
| public Dimension | Returns: aDimension object containing
the preferred sizeOverrides javax. Overrides |
| public void | setBorder(Border
the border to be rendered for this component border)Overrides javax. Sets the border of this component. |
| border | back to summary |
|---|---|
| protected Border border Hides javax. Border to use. | |
| DefaultTextField | back to summary |
|---|---|
| public DefaultTextField(Border border) Constructs a
| |
| getBorder | back to summary |
|---|---|
| public Border getBorder() Overrides javax. Overrides | |
| getFont | back to summary |
|---|---|
| public Font getFont() Overrides java. Implements java. Doc from java. Gets the font of this component. | |
| getPreferredSize | back to summary |
|---|---|
| public Dimension getPreferredSize() Overrides javax. Overrides
| |
| setBorder | back to summary |
|---|---|
| public void setBorder(Border border) Overrides javax. Sets the border of this component. This is a bound property.
| |
editingComponent.
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private int | |
| public void | |
| public void | |
| public Dimension | Returns: aDimension containing the preferred
size for the Container; if
editingComponent is null the
Dimension returned is 0, 0Overrides java. Returns the preferred size for the |
| public void | paint(Graphics g)
Overrides java. Overrides |
| EditorContainer | back to summary |
|---|---|
| public EditorContainer() Constructs an | |
| calculateIconY | back to summary |
|---|---|
| private int calculateIconY(Icon icon) Calculate the y location for the icon. | |
| doLayout | back to summary |
|---|---|
| public void doLayout() Overrides java. Lays out this | |
| EditorContainer | back to summary |
|---|---|
| public void EditorContainer() Do not use. | |
| getPreferredSize | back to summary |
|---|---|
| public Dimension getPreferredSize() Overrides java. Returns the preferred size for the
| |
| paint | back to summary |
|---|---|
| public void paint(Graphics g) Overrides java. Overrides | |