Skip to content

TreeCellRenderer

Add padding to the strings in JTree nodes.

Section titled “Add padding to the strings in JTree nodes.”
Add padding to the strings in JTree nodes.

TreeCellMargin

This adds margins to the left and right of the text in a JTree node.

Search for and highlight nodes that match the criteria in JTree.

Section titled “Search for and highlight nodes that match the criteria in JTree.”
Search for and highlight nodes that match the criteria in JTree.

TreeNodeHighlightSearch

Search for a JTree and highlight the node using TreeCellRenderer.

Select a row in the JTree by clicking on it, and then draw the entire row with the background color of the selected row.

Section titled “Select a row in the JTree by clicking on it, and then draw the entire row with the background color of the selected row.”
Select a row in the JTree by clicking on it, and then draw the entire row with the background color of the selected row.

TreeRowSelection

Click on a row in the JTree to select it, and then draw the entire row with the background color of the selected row.

Displaying JTree node titles across multiple lines

Section titled “Displaying JTree node titles across multiple lines”
Displaying JTree node titles across multiple lines

MultiLineTree

Use line breaks in each node of the JTree to display the title across multiple lines.

Displaying JComboBox items in a tree-like structure

Section titled “Displaying JComboBox items in a tree-like structure”
Displaying JComboBox items in a tree-like structure

TreeComboBox

The items to be displayed in the JComboBox dropdown list are arranged in a tree-like structure.

JTree node icon size and text selection state

Section titled “JTree node icon size and text selection state”
JTree node icon size and text selection state

TreeRowHeightCellMargin

This fixes the issue where the text selection state changes when the row height is altered by the node icon in JTree.

Change the background color of the selected item in JTree.

Section titled “Change the background color of the selected item in JTree.”
Change the background color of the selected item in JTree.

TreeBackgroundSelectionColor

This changes the background color of selected JTree nodes based on their node conditions.

Make the JTree transparent and the selected state semi-transparent.

Section titled “Make the JTree transparent and the selected state semi-transparent.”
Make the JTree transparent and the selected state semi-transparent.

TranslucentTree

This makes the background of the JTree transparent and the selected node color semi-transparent.

Highlight the strings within JTree nodes.

HighlightWordInNode

This program searches for a string within a JTree node and highlights it using HighlightPainter.

Display a JProgressBar in a JTree node.

TreeNodeProgressBar

Set up a TreeCellRenderer on the JTree node to display a JProgressBar.

Create a table of contents with JTree

TableOfContentsTree

This creates a table of contents by adding a leader and page number to the JTree node.

Limit JTree cell selection to nodes instead of entire rows using NimbusLookAndFeel.

Section titled “Limit JTree cell selection to nodes instead of entire rows using NimbusLookAndFeel.”
Limit JTree cell selection to nodes instead of entire rows using NimbusLookAndFeel.

TreeCellSelectionBackground

This sets the range that fills cells with the selected color in JTree to only the nodes, rather than the entire row as is the default setting in NimbusLookAndFeel.

Automatically add and display chapter numbers to the titles of each node in JTree.

Section titled “Automatically add and display chapter numbers to the titles of each node in JTree.”
Automatically add and display chapter numbers to the titles of each node in JTree.

AutoChapterNumberingTreeNode

We will create a TreeCellRenderer that automatically adds chapter numbers to each node in the JTree and displays them at the beginning of the title.