Class SynthTreeUI
java.lang.Object
javax.swing.plaf.ComponentUI
javax.swing.plaf.TreeUI
javax.swing.plaf.basic.BasicTreeUI
javax.swing.plaf.synth.SynthTreeUI
- All Implemented Interfaces:
PropertyChangeListener, EventListener, SynthConstants, SynthUI
public class SynthTreeUI extends BasicTreeUI implements PropertyChangeListener, SynthUI
Provides the Synth L&F UI delegate for
JTree.- Since:
- 1.7
Nested Class Summary
Nested classes/interfaces declared in class BasicTreeUI
BasicTreeUI.CellEditorHandler, BasicTreeUI.ComponentHandler, BasicTreeUI.FocusHandler, BasicTreeUI.KeyHandler, BasicTreeUI.MouseHandler, BasicTreeUI.MouseInputHandler, BasicTreeUI.NodeDimensionsHandler, BasicTreeUI.PropertyChangeHandler, BasicTreeUI.SelectionModelPropertyChangeHandler, BasicTreeUI.TreeCancelEditingAction, BasicTreeUI.TreeExpansionHandler, BasicTreeUI.TreeHomeAction, BasicTreeUI.TreeIncrementAction, BasicTreeUI.TreeModelHandler, BasicTreeUI.TreePageAction, BasicTreeUI.TreeSelectionHandler, BasicTreeUI.TreeToggleAction, BasicTreeUI.TreeTraverseAction | Modifier and Type | Class | Description |
|---|---|---|
class |
BasicTreeUI.CellEditorHandler |
Listener responsible for getting cell editing events and updating the tree accordingly. |
class |
BasicTreeUI.ComponentHandler |
Updates the preferred size when scrolling (if necessary). |
class |
BasicTreeUI.FocusHandler |
Repaints the lead selection row when focus is lost/gained. |
class |
BasicTreeUI.KeyHandler |
This is used to get multiple key down events to appropriately generate events. |
class |
BasicTreeUI.MouseHandler |
TreeMouseListener is responsible for updating the selection based on mouse events. |
class |
BasicTreeUI.MouseInputHandler |
MouseInputHandler handles passing all mouse events, including mouse motion events, until the mouse is released to the destination it is constructed with. |
class |
BasicTreeUI.NodeDimensionsHandler |
Class responsible for getting size of node, method is forwarded to BasicTreeUI method. |
class |
BasicTreeUI.PropertyChangeHandler |
PropertyChangeListener for the tree. |
class |
BasicTreeUI.SelectionModelPropertyChangeHandler |
Listener on the TreeSelectionModel, resets the row selection if any of the properties of the model change. |
class |
BasicTreeUI.TreeCancelEditingAction |
ActionListener that invokes cancelEditing when action performed. |
class |
BasicTreeUI.TreeExpansionHandler |
Updates the TreeState in response to nodes expanding/collapsing. |
class |
BasicTreeUI.TreeHomeAction |
TreeHomeAction is used to handle end/home actions. |
class |
BasicTreeUI.TreeIncrementAction |
TreeIncrementAction is used to handle up/down actions. |
class |
BasicTreeUI.TreeModelHandler |
Forwards all TreeModel events to the TreeState. |
class |
BasicTreeUI.TreePageAction |
TreePageAction handles page up and page down events. |
class |
BasicTreeUI.TreeSelectionHandler |
Listens for changes in the selection model and updates the display accordingly. |
class |
BasicTreeUI.TreeToggleAction |
For the first selected row expandedness will be toggled. |
class |
BasicTreeUI.TreeTraverseAction |
TreeTraverseAction is the action used for left/right keys. |
Field Summary
Fields declared in class BasicTreeUI
cellEditor, collapsedIcon, createdCellEditor, createdRenderer, currentCellRenderer, depthOffset, drawingCache, editingComponent, editingPath, editingRow, editorHasDifferentSize, expandedIcon, largeModel, lastSelectedRow, leftChildIndent, nodeDimensions, preferredMinSize, preferredSize, rendererPane, rightChildIndent, stopEditingInCompleteEditing, totalChildIndent, tree, treeModel, treeSelectionModel, treeState, validCachedPreferredSize | Modifier and Type | Field | Description |
|---|---|---|
protected TreeCellEditor |
cellEditor |
Editor for the tree. |
protected Icon |
collapsedIcon |
The collapsed icon. |
protected boolean |
createdCellEditor |
Set to true if editor that is currently in the tree was created by this instance. |
protected boolean |
createdRenderer |
Set to true if the renderer that is currently in the tree was created by this instance. |
protected TreeCellRenderer |
currentCellRenderer |
Renderer that is being used to do the actual cell drawing. |
protected int |
depthOffset |
How much the depth should be offset to properly calculate x locations. |
protected Hashtable |
drawingCache |
Used for minimizing the drawing of vertical lines. |
protected Component |
editingComponent |
When editing, this will be the Component that is doing the actual editing. |
protected TreePath |
editingPath |
Path that is being edited. |
protected int |
editingRow |
Row that is being edited. |
protected boolean |
editorHasDifferentSize |
Set to true if the editor has a different size than the renderer. |
protected Icon |
expandedIcon |
The expanded icon. |
protected boolean |
largeModel |
True if doing optimizations for a largeModel. |
protected int |
lastSelectedRow |
Index of the row that was last selected. |
protected int |
leftChildIndent |
Distance between left margin and where vertical dashes will be drawn. |
protected AbstractLayoutCache.NodeDimensions |
nodeDimensions |
Responsible for telling the TreeState the size needed for a node. |
protected Dimension |
preferredMinSize |
Minimum preferred size. |
protected Dimension |
preferredSize |
Size needed to completely display all the nodes. |
protected CellRendererPane |
rendererPane |
Used to paint the TreeCellRenderer. |
protected int |
rightChildIndent |
Distance to add to leftChildIndent to determine where cell contents will be drawn. |
protected boolean |
stopEditingInCompleteEditing |
Set to false when editing and shouldSelectCell() returns true meaning the node should be selected before editing, used in completeEditing. |
protected int |
totalChildIndent |
Total distance that will be indented. |
protected JTree |
tree |
Component that we're going to be drawing into. |
protected TreeModel |
treeModel |
Used to determine what to display. |
protected TreeSelectionModel |
treeSelectionModel |
Model maintaining the selection. |
protected AbstractLayoutCache |
treeState |
Object responsible for handling sizing and expanded issues. |
protected boolean |
validCachedPreferredSize |
Is the preferredSize valid? |
Fields declared in interface SynthConstants
DEFAULT, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED, SELECTED | Modifier and Type | Field | Description |
|---|---|---|
static final int |
DEFAULT |
Indicates the region is the default. |
static final int |
DISABLED |
Primary state indicating the region is not enabled. |
static final int |
ENABLED |
Primary state indicating the component is enabled. |
static final int |
FOCUSED |
Indicates the region has focus. |
static final int |
MOUSE_OVER |
Primary state indicating the mouse is over the region. |
static final int |
PRESSED |
Primary state indicating the region is in a pressed state. |
static final int |
SELECTED |
Indicates the region is selected. |
Constructor Summary
| Constructor | Description |
|---|---|
SynthTreeUI() |
Constructs a SynthTreeUI. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
static ComponentUI |
createUI |
Creates a new UI object for the given component. |
SynthContext |
getContext |
Returns the Context for the specified component. |
void |
paint |
Paints the specified component according to the Look and Feel. |
protected void |
paint |
Paints the specified component. |
void |
paintBorder |
Paints the border. |
void |
propertyChange |
This method gets called when a bound property is changed. |
void |
update |
Notifies this UI delegate to repaint the specified component. |
Methods declared in class BasicTreeUI
cancelEditing, checkForClickInExpandControl, completeEditing, completeEditing, completeUIInstall, completeUIUninstall, configureLayoutCache, createCellEditorListener, createCellRendererPane, createComponentListener, createDefaultCellEditor, createDefaultCellRenderer, createFocusListener, createKeyListener, createLayoutCache, createMouseListener, createNodeDimensions, createPropertyChangeListener, createSelectionModelPropertyChangeListener, createTreeExpansionListener, createTreeModelListener, createTreeSelectionListener, drawCentered, drawDashedHorizontalLine, drawDashedVerticalLine, ensureRowsAreVisible, getBaseline, getBaselineResizeBehavior, getCellEditor, getCellRenderer, getClosestPathForLocation, getCollapsedIcon, getDropLineRect, getEditingPath, getExpandedIcon, getHashColor, getHorizontalLegBuffer, getLastChildPath, getLeadSelectionRow, getLeftChildIndent, getMaximumSize, getMinimumSize, getModel, getPathBounds, getPathForRow, getPreferredMinSize, getPreferredSize, getPreferredSize, getRightChildIndent, getRowCount, getRowForPath, getRowHeight, getRowX, getSelectionModel, getShowsRootHandles, getVerticalLegBuffer, handleExpandControlClick, installComponents, installDefaults, installKeyboardActions, installListeners, isDropLine, isEditable, isEditing, isLargeModel, isLeaf, isLocationInExpandControl, isMultiSelectEvent, isRootVisible, isToggleEvent, isToggleSelectionEvent, paintDropLine, paintExpandControl, paintHorizontalLine, paintHorizontalPartOfLeg, paintRow, paintVerticalLine, paintVerticalPartOfLeg, pathWasCollapsed, pathWasExpanded, prepareForUIInstall, prepareForUIUninstall, selectPathForEvent, setCellEditor, setCellRenderer, setCollapsedIcon, setEditable, setExpandedIcon, setHashColor, setLargeModel, setLeftChildIndent, setModel, setPreferredMinSize, setRightChildIndent, setRootVisible, setRowHeight, setSelectionModel, setShowsRootHandles, shouldPaintExpandControl, startEditing, startEditingAtPath, stopEditing, toggleExpandState, uninstallComponents, uninstallDefaults, uninstallKeyboardActions, uninstallListeners, updateCachedPreferredSize, updateCellEditor, updateDepthOffset, updateExpandedDescendants, updateLayoutCacheExpandedNodes, updateLeadSelectionRow, updateRenderer, updateSize | Modifier and Type | Method | Description |
|---|---|---|
void |
cancelEditing |
Cancels the current editing session. |
protected void |
checkForClickInExpandControl |
If the mouseX and mouseY are in the expand/collapse region of the row, this will toggle the row. |
protected void |
completeEditing() |
Messages to stop the editing session. |
protected void |
completeEditing |
Stops the editing session. |
protected void |
completeUIInstall() |
Invoked from installUI after all the defaults/listeners have been installed. |
protected void |
completeUIUninstall() |
Uninstalls UI. |
protected void |
configureLayoutCache() |
Resets the TreeState instance based on the tree we're providing the look and feel for. |
protected CellEditorListener |
createCellEditorListener() |
Creates a listener to handle events from the current editor. |
protected CellRendererPane |
createCellRendererPane() |
Returns the renderer pane that renderer components are placed in. |
protected ComponentListener |
createComponentListener() |
Creates and returns a new ComponentHandler. |
protected TreeCellEditor |
createDefaultCellEditor() |
Creates a default cell editor. |
protected TreeCellRenderer |
createDefaultCellRenderer() |
Returns the default cell renderer that is used to do the stamping of each node. |
protected FocusListener |
createFocusListener() |
Creates a listener that is responsible for updating the display when focus is lost/gained. |
protected KeyListener |
createKeyListener() |
Creates the listener responsible for getting key events from the tree. |
protected AbstractLayoutCache |
createLayoutCache() |
Creates the object responsible for managing what is expanded, as well as the size of nodes. |
protected MouseListener |
createMouseListener() |
Creates the listener responsible for updating the selection based on mouse events. |
protected AbstractLayoutCache.NodeDimensions |
createNodeDimensions() |
Creates an instance of NodeDimensions that is able to determine the size of a given node in the tree. |
protected PropertyChangeListener |
createPropertyChangeListener() |
Creates a listener that is responsible that updates the UI based on how the tree changes. |
protected PropertyChangeListener |
createSelectionModelPropertyChangeListener() |
Creates the listener responsible for getting property change events from the selection model. |
protected TreeExpansionListener |
createTreeExpansionListener() |
Creates and returns the object responsible for updating the treestate when nodes expanded state changes. |
protected TreeModelListener |
createTreeModelListener() |
Returns a listener that can update the tree when the model changes. |
protected TreeSelectionListener |
createTreeSelectionListener() |
Creates the listener that updates the display based on selection change methods. |
protected void |
drawCentered |
Draws the icon centered at (x,y). |
protected void |
drawDashedHorizontalLine |
Draws a horizontal dashed line. |
protected void |
drawDashedVerticalLine |
Draws a vertical dashed line. |
protected void |
ensureRowsAreVisible |
Ensures that the rows identified by beginRow through endRow are visible. |
int |
getBaseline |
Returns the baseline. |
Component.BaselineResizeBehavior |
getBaselineResizeBehavior |
Returns an enum indicating how the baseline of the component changes as the size changes. |
protected TreeCellEditor |
getCellEditor() |
Returns the editor used to edit entries in the drawn tree component, or null if the tree cannot be edited. |
protected TreeCellRenderer |
getCellRenderer() |
Returns the current instance of the TreeCellRenderer that is rendering each cell. |
TreePath |
getClosestPathForLocation |
Returns the path to the node that is closest to x,y. |
Icon |
getCollapsedIcon() |
Returns the collapsed icon. |
protected Rectangle |
getDropLineRect |
Returns a unbounding box for the drop line. |
TreePath |
getEditingPath |
Returns the path to the element that is being edited. |
Icon |
getExpandedIcon() |
Returns the expanded icon. |
protected Color |
getHashColor() |
Returns the hash color. |
protected int |
getHorizontalLegBuffer() |
The horizontal element of legs between nodes starts at the right of the left-hand side of the child node by default. |
protected TreePath |
getLastChildPath |
Returns a path to the last child of parent. |
protected int |
getLeadSelectionRow() |
Returns the lead row of the selection. |
int |
getLeftChildIndent() |
Returns the left child indent. |
Dimension |
getMaximumSize |
Returns the maximum size for this component, which will be the preferred size if the instance is currently in a JTree, or 0, 0. |
Dimension |
getMinimumSize |
Returns the minimum size for this component. |
protected TreeModel |
getModel() |
Returns the tree model. |
Rectangle |
getPathBounds |
Returns the Rectangle enclosing the label portion that the last item in path will be drawn into. |
TreePath |
getPathForRow |
Returns the path for passed in row. |
Dimension |
getPreferredMinSize() |
Returns the minimum preferred size. |
Dimension |
getPreferredSize |
Returns the preferred size to properly display the tree, this is a cover method for getPreferredSize(c, true). |
Dimension |
getPreferredSize |
Returns the preferred size to represent the tree in c. |
int |
getRightChildIndent() |
Returns the right child indent. |
int |
getRowCount |
Returns the number of rows that are being displayed. |
int |
getRowForPath |
Returns the row that the last item identified in path is visible at. |
protected int |
getRowHeight() |
Returns the height of each row in the drawn tree component. |
protected int |
getRowX |
Returns the location, along the x-axis, to render a particular row at. |
protected TreeSelectionModel |
getSelectionModel() |
Returns the current instance of the TreeSelectionModel which is the model for selections. |
protected boolean |
getShowsRootHandles() |
Returns true if the root handles are to be displayed. |
protected int |
getVerticalLegBuffer() |
The vertical element of legs between nodes starts at the bottom of the parent node by default. |
protected void |
handleExpandControlClick |
Messaged when the user clicks the particular row, this invokes toggleExpandState. |
protected void |
installComponents() |
Installs the subcomponents of the tree, which is the renderer pane. |
protected void |
installDefaults() |
Installs default properties. |
protected void |
installKeyboardActions() |
Registers keyboard actions. |
protected void |
installListeners() |
Registers listeners. |
protected boolean |
isDropLine |
Tells if a DropLocation should be indicated by a line between nodes. |
protected boolean |
isEditable() |
Returns whether the drawn tree component should be enabled for editing. |
boolean |
isEditing |
Returns true if the tree is being edited. |
protected boolean |
isLargeModel() |
Returns true if large model is set. |
protected boolean |
isLeaf |
Returns true if the node at row is a leaf. |
protected boolean |
isLocationInExpandControl |
Returns true if mouseX and mouseY fall in the area of row that is used to expand/collapse the node and the node at row does not represent a leaf. |
protected boolean |
isMultiSelectEvent |
Returning true signifies a mouse event on the node should select from the anchor point. |
protected boolean |
isRootVisible() |
Returns whether the root node of the drawn tree component should be displayed. |
protected boolean |
isToggleEvent |
Returning true indicates the row under the mouse should be toggled based on the event. |
protected boolean |
isToggleSelectionEvent |
Returning true signifies a mouse event on the node should toggle the selection of only the row under mouse. |
protected void |
paintDropLine |
Paints the drop line. |
protected void |
paintExpandControl |
Paints the expand (toggle) part of a row. |
protected void |
paintHorizontalLine |
Paints a horizontal line. |
protected void |
paintHorizontalPartOfLeg |
Paints the horizontal part of the leg. |
protected void |
paintRow |
Paints the renderer part of a row. |
protected void |
paintVerticalLine |
Paints a vertical line. |
protected void |
paintVerticalPartOfLeg |
Paints the vertical part of the leg. |
protected void |
pathWasCollapsed |
Messaged from the VisibleTreeNode after it has collapsed. |
protected void |
pathWasExpanded |
Messaged from the VisibleTreeNode after it has been expanded. |
protected void |
prepareForUIInstall() |
Invoked after the tree instance variable has been set, but before any defaults/listeners have been installed. |
protected void |
prepareForUIUninstall() |
Invoked before uninstallation of UI. |
protected void |
selectPathForEvent |
Messaged to update the selection based on a MouseEvent over a particular row. |
protected void |
setCellEditor |
Sets the cell editor. |
protected void |
setCellRenderer |
Sets the TreeCellRenderer to tcr. |
void |
setCollapsedIcon |
Sets the collapsed icon. |
protected void |
setEditable |
Configures the receiver to allow, or not allow, editing. |
void |
setExpandedIcon |
Sets the expanded icon. |
protected void |
setHashColor |
Sets the hash color. |
protected void |
setLargeModel |
Sets the largeModel. |
void |
setLeftChildIndent |
Sets the left child indent. |
protected void |
setModel |
Sets the TreeModel. |
void |
setPreferredMinSize |
Sets the preferred minimum size. |
void |
setRightChildIndent |
Sets the right child indent. |
protected void |
setRootVisible |
Sets the root to being visible. |
protected void |
setRowHeight |
Sets the row height, this is forwarded to the treeState. |
protected void |
setSelectionModel |
Resets the selection model. |
protected void |
setShowsRootHandles |
Determines whether the node handles are to be displayed. |
protected boolean |
shouldPaintExpandControl |
Returns true if the expand (toggle) control should be drawn for the specified row. |
protected boolean |
startEditing |
Will start editing for node if there is a cellEditor and shouldSelectCell returns true. |
void |
startEditingAtPath |
Selects the last item in path and tries to edit it. |
boolean |
stopEditing |
Stops the current editing session. |
protected void |
toggleExpandState |
Expands path if it is not expanded, or collapses row if it is expanded. |
protected void |
uninstallComponents() |
Uninstalls the renderer pane. |
protected void |
uninstallDefaults() |
Uninstalls default properties. |
protected void |
uninstallKeyboardActions() |
Unregisters keyboard actions. |
protected void |
uninstallListeners() |
Unregisters listeners. |
protected void |
updateCachedPreferredSize() |
Updates the preferredSize instance variable, which is returned from getPreferredSize(). |
protected void |
updateCellEditor() |
Updates the cellEditor based on the editability of the JTree that we're contained in. |
protected void |
updateDepthOffset() |
Updates how much each depth should be offset by. |
protected void |
updateExpandedDescendants |
Updates the expanded state of all the descendants of path by getting the expanded descendants from the tree and forwarding to the tree state. |
protected void |
updateLayoutCacheExpandedNodes() |
Makes all the nodes that are expanded in JTree expanded in LayoutCache. |
protected void |
updateLeadSelectionRow() |
Updates the lead row of the selection. |
protected void |
updateRenderer() |
Messaged from the tree we're in when the renderer has changed. |
protected void |
updateSize() |
Marks the cached size as being invalid, and messages the tree with treeDidChange. |
Methods declared in class ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, installUI, uninstallUI | Modifier and Type | Method | Description |
|---|---|---|
boolean |
contains |
Returns true if the specified x,y location is contained within the look and feel's defined shape of the specified component. |
Accessible |
getAccessibleChild |
Returns the ith Accessible child of the object. |
int |
getAccessibleChildrenCount |
Returns the number of accessible children in the object. |
void |
installUI |
Configures the specified component appropriately for the look and feel. |
void |
uninstallUI |
Reverses configuration which was done on the specified component during installUI. |
Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | Modifier and Type | Method | Description |
|---|---|---|
protected Object |
clone() |
Creates and returns a copy of this object. |
boolean |
equals |
Indicates whether some other object is "equal to" this one. |
protected void |
finalize() |
Deprecated, for removal: This API element is subject to removal in a future version. Finalization is deprecated and subject to removal in a future release. |
final Class |
getClass() |
Returns the runtime class of this Object. |
int |
hashCode() |
Returns a hash code value for this object. |
final void |
notify() |
Wakes up a single thread that is waiting on this object's monitor. |
final void |
notifyAll() |
Wakes up all threads that are waiting on this object's monitor. |
String |
toString() |
Returns a string representation of the object. |
final void |
wait() |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted. |
final void |
wait |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. |
final void |
wait |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. |
Constructor Details
SynthTreeUI
public SynthTreeUI()
Constructs a
SynthTreeUI.Method Details
createUI
public static ComponentUI createUI(JComponent x)
Creates a new UI object for the given component.
- Parameters:
-
x- component to create UI object for - Returns:
- the UI object
getContext
public SynthContext getContext(JComponent c)
Returns the Context for the specified component.
- Specified by:
-
getContextin interfaceSynthUI - Parameters:
-
c- Component requesting SynthContext. - Returns:
- SynthContext describing component.
update
public void update(Graphics g, JComponent c)
Notifies this UI delegate to repaint the specified component. This method paints the component background, then calls the
paint(SynthContext,Graphics) method. In general, this method does not need to be overridden by subclasses. All Look and Feel rendering code should reside in the paint method.
- Overrides:
-
updatein classComponentUI - Parameters:
-
g- theGraphicsobject used for painting -
c- the component being painted - See Also:
paintBorder
public void paintBorder(SynthContext context, Graphics g, int x, int y, int w, int h)
Paints the border.
- Specified by:
-
paintBorderin interfaceSynthUI - Parameters:
-
context- a component context -
g-Graphicsto paint on -
x- the X coordinate -
y- the Y coordinate -
w- width of the border -
h- height of the border
paint
public void paint(Graphics g, JComponent c)
Paints the specified component according to the Look and Feel.
This method is not used by Synth Look and Feel. Painting is handled by the paint(SynthContext,Graphics) method.
- Overrides:
-
paintin classComponentUI - Parameters:
-
g- theGraphicsobject used for painting -
c- the component being painted - See Also:
paint
protected void paint(SynthContext context, Graphics g)
Paints the specified component.
- Parameters:
-
context- context for the component being painted -
g- theGraphicsobject used for painting - See Also:
propertyChange
public void propertyChange(PropertyChangeEvent event)
This method gets called when a bound property is changed.
- Specified by:
-
propertyChangein interfacePropertyChangeListener - Parameters:
-
event- A PropertyChangeEvent object describing the event source and the property that has changed.
© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.