oper.apple.com/documentation/UserExperience/Conceptual/AppleHIGuidelines/XHIGWindows/chapter_18_section_4.html#//apple_ref/doc/uid/20000961-CHDDIGDE">Apple definedSource List. While this UI delegate can be directly installed on existing {@code JTree}s, it is recommended that you use the {@link MacWidgetFactory#makeSourceList(javax.swing.JTree)} methodin conjuction with {@link MacWidgetFactory#createSourceListScrollPane(javax.swing.JComponent)}.
For the best development experience, it is recommended that you migrate your code to use the {@link SourceList} with the {@link SourceListModel}, as this component abstracts away many of the complexities of {@code JTree}.
Pictured below are the two different rendering styles of a Source List: focused and unfocused. The corresponding {@code 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 {@link DefaultMutableTreeNode}, and the {@link DefaultMutableTreeNode#getUserObject()} is an instance of {@link TextProvider}, then the {@code TextProvider} will be queried for the node text.
- If no implementation of {@code TextProvider} is found, the standard{@link JTree#convertValueToText(Object,boolean,boolean,boolean,int,boolean)} method willbe 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:
- If the node is an instance of {@link DefaultMutableTreeNode}, and the {@link DefaultMutableTreeNode#getUserObject()} is an instance of {@link IconProvider}, then the {@code IconProvider} will be queried for the node icon.