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 theTextProviderwill be queried for the node text. - If no implementation of
TextProvideris 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 theIconProviderwill 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 voidprotected AbstractLayoutCache.NodeDimensionsGets theSourceListColorSchemethat thisSourceListTreeUIuses to paint.getPathBounds(JTree tree, TreePath path) protected voidprotected voidvoidpaint(Graphics g, JComponent c) protected voidpaintExpandControl(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) protected voidpaintHorizontalLine(Graphics g, JComponent c, int y, int left, int right) protected voidpaintVerticalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, TreePath path) protected voidselectPathForEvent(TreePath path, MouseEvent event) voidsetCategoryFont(Font categoryFont) voidsetColorScheme(SourceListColorScheme colorScheme) Sets theSourceListColorSchemethat thisSourceListTreeUIuses to paint.voidsetItemFont(Font itemFont) voidsetItemSelectedFont(Font itemSelectedFont) protected voidMethods 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, updateSizeMethods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, update
-
Constructor Details
-
SourceListTreeUI
public SourceListTreeUI()
-
-
Method Details
-
completeUIInstall
protected void completeUIInstall()- Overrides:
completeUIInstallin classBasicTreeUI
-
getCategoryFont
-
setCategoryFont
-
getItemFont
-
setItemFont
-
getItemSelectedFont
-
setItemSelectedFont
-
installListeners
protected void installListeners()- Overrides:
installListenersin classBasicTreeUI
-
installKeyboardActions
protected void installKeyboardActions()- Overrides:
installKeyboardActionsin classBasicTreeUI
-
setModel
- Overrides:
setModelin classBasicTreeUI
-
getColorScheme
Gets theSourceListColorSchemethat thisSourceListTreeUIuses to paint.- Returns:
- the
SourceListColorSchemethat thisSourceListuses to paint.
-
setColorScheme
Sets theSourceListColorSchemethat thisSourceListTreeUIuses to paint.- Parameters:
colorScheme- theSourceListColorSchemethat thisSourceListuses 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:
paintExpandControlin classBasicTreeUI
-
createNodeDimensions
- Overrides:
createNodeDimensionsin classBasicTreeUI
-
getPathBounds
- Overrides:
getPathBoundsin classBasicTreeUI
-
paint
- Overrides:
paintin classBasicTreeUI
-
paintHorizontalLine
- Overrides:
paintHorizontalLinein classBasicTreeUI
-
paintVerticalPartOfLeg
protected void paintVerticalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, TreePath path) - Overrides:
paintVerticalPartOfLegin classBasicTreeUI
-
selectPathForEvent
- Overrides:
selectPathForEventin classBasicTreeUI
-

