Class SourceListTreeUI


public class SourceListTreeUI extends BasicTreeUI

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:

  1. If the node is an instance of DefaultMutableTreeNode, and the DefaultMutableTreeNode.getUserObject() is an instance of TextProvider, then the TextProvider will be queried for the node text.
  2. If no implementation of TextProvider is found, the standard JTree.convertValueToText(Object, boolean, boolean, boolean, int, boolean) method will be consulted.
Also, during rendering, each Item node will be consulted for an icon. Similarly to the above mechanism for determining text, the render determines a nodes icon by the following check:
  1. If the node is an instance of DefaultMutableTreeNode, and the DefaultMutableTreeNode.getUserObject() is an instance of IconProvider, then the IconProvider will be queried for the node icon.