Class SourceListTreeUI
java.lang.Object
javax.swing.plaf.ComponentUI
javax.swing.plaf.TreeUI
javax.swing.plaf.basic.BasicTreeUI
com.explodingpixels.macwidgets.plaf.SourceListTreeUI
A UI delegate that paints a JTree
as an Apple defined
Source List. Consider using this UI delegate with
MacWidgetFactory.createSourceListScrollPane(javax.swing.JComponent)
.
For the best development experience, it is recommended that you migrate your code to use the
SourceList
with the SourceListModel
, as this component abstracts away many of the
complexities of JTree
.
Pictured below are the two different rendering styles of a Source List: focused and unfocused.
The corresponding JTree
's focusable property drives this rendering style.
![]() |
![]() |
Focusable SourceList | Non-focusable SourceList |
Providing Category and Item text and icons
During the rendering process, each Category and Item node will be consulted for the text to be displayed. The renderer determines the text based on these prioritized checks:- If the node is an instance of
DefaultMutableTreeNode
, and theDefaultMutableTreeNode.getUserObject()
is an instance ofTextProvider
, then theTextProvider
will be queried for the node text. - If no implementation of
TextProvider
is found, the standardJTree.convertValueToText(Object, boolean, boolean, boolean, int, boolean)
method will be consulted.
- If the node is an instance of
DefaultMutableTreeNode
, and theDefaultMutableTreeNode.getUserObject()
is an instance ofIconProvider
, then theIconProvider
will be queried for the node icon.
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.plaf.basic.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
-
Field Summary
Fields inherited from class javax.swing.plaf.basic.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
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
protected AbstractLayoutCache.NodeDimensions
Gets theSourceListColorScheme
that thisSourceListTreeUI
uses to paint.getPathBounds
(JTree tree, TreePath path) protected void
protected void
void
paint
(Graphics g, JComponent c) protected void
paintExpandControl
(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) protected void
paintHorizontalLine
(Graphics g, JComponent c, int y, int left, int right) protected void
paintVerticalPartOfLeg
(Graphics g, Rectangle clipBounds, Insets insets, TreePath path) protected void
selectPathForEvent
(TreePath path, MouseEvent event) void
setCategoryFont
(Font categoryFont) void
setColorScheme
(SourceListColorScheme colorScheme) Sets theSourceListColorScheme
that thisSourceListTreeUI
uses to paint.void
setItemFont
(Font itemFont) void
setItemSelectedFont
(Font itemSelectedFont) protected void
Methods inherited from class javax.swing.plaf.basic.BasicTreeUI
cancelEditing, checkForClickInExpandControl, completeEditing, completeEditing, completeUIUninstall, configureLayoutCache, createCellEditorListener, createCellRendererPane, createComponentListener, createDefaultCellEditor, createDefaultCellRenderer, createFocusListener, createKeyListener, createLayoutCache, createMouseListener, createPropertyChangeListener, createSelectionModelPropertyChangeListener, createTreeExpansionListener, createTreeModelListener, createTreeSelectionListener, createUI, drawCentered, drawDashedHorizontalLine, drawDashedVerticalLine, ensureRowsAreVisible, getBaseline, getBaselineResizeBehavior, getCellEditor, getCellRenderer, getClosestPathForLocation, getCollapsedIcon, getDropLineRect, getEditingPath, getExpandedIcon, getHashColor, getHorizontalLegBuffer, getLastChildPath, getLeadSelectionRow, getLeftChildIndent, getMaximumSize, getMinimumSize, getModel, getPathForRow, getPreferredMinSize, getPreferredSize, getPreferredSize, getRightChildIndent, getRowCount, getRowForPath, getRowHeight, getRowX, getSelectionModel, getShowsRootHandles, getVerticalLegBuffer, handleExpandControlClick, installComponents, installDefaults, installUI, isDropLine, isEditable, isEditing, isLargeModel, isLeaf, isLocationInExpandControl, isMultiSelectEvent, isRootVisible, isToggleEvent, isToggleSelectionEvent, paintDropLine, paintHorizontalPartOfLeg, paintRow, paintVerticalLine, pathWasCollapsed, pathWasExpanded, prepareForUIInstall, prepareForUIUninstall, setCellEditor, setCellRenderer, setCollapsedIcon, setEditable, setExpandedIcon, setHashColor, setLargeModel, setLeftChildIndent, setPreferredMinSize, setRightChildIndent, setRootVisible, setRowHeight, setSelectionModel, setShowsRootHandles, shouldPaintExpandControl, startEditing, startEditingAtPath, stopEditing, toggleExpandState, uninstallComponents, uninstallDefaults, uninstallKeyboardActions, uninstallListeners, uninstallUI, updateCachedPreferredSize, updateCellEditor, updateDepthOffset, updateExpandedDescendants, updateLayoutCacheExpandedNodes, updateLeadSelectionRow, updateRenderer, updateSize
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, update
-
Constructor Details
-
SourceListTreeUI
public SourceListTreeUI()
-
-
Method Details
-
completeUIInstall
protected void completeUIInstall()- Overrides:
completeUIInstall
in classBasicTreeUI
-
getCategoryFont
-
setCategoryFont
-
getItemFont
-
setItemFont
-
getItemSelectedFont
-
setItemSelectedFont
-
installListeners
protected void installListeners()- Overrides:
installListeners
in classBasicTreeUI
-
installKeyboardActions
protected void installKeyboardActions()- Overrides:
installKeyboardActions
in classBasicTreeUI
-
setModel
- Overrides:
setModel
in classBasicTreeUI
-
getColorScheme
Gets theSourceListColorScheme
that thisSourceListTreeUI
uses to paint.- Returns:
- the
SourceListColorScheme
that thisSourceList
uses to paint.
-
setColorScheme
Sets theSourceListColorScheme
that thisSourceListTreeUI
uses to paint.- Parameters:
colorScheme
- theSourceListColorScheme
that thisSourceList
uses to paint.
-
paintExpandControl
protected void paintExpandControl(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) - Overrides:
paintExpandControl
in classBasicTreeUI
-
createNodeDimensions
- Overrides:
createNodeDimensions
in classBasicTreeUI
-
getPathBounds
- Overrides:
getPathBounds
in classBasicTreeUI
-
paint
- Overrides:
paint
in classBasicTreeUI
-
paintHorizontalLine
- Overrides:
paintHorizontalLine
in classBasicTreeUI
-
paintVerticalPartOfLeg
protected void paintVerticalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, TreePath path) - Overrides:
paintVerticalPartOfLeg
in classBasicTreeUI
-
selectPathForEvent
- Overrides:
selectPathForEvent
in classBasicTreeUI
-