llms.txt: machine-readable documentation index. Markdown version of this page is also available.

IntelliJ Platform Plugin SDK Help

List and Tree Controls

JBList and Tree

Instead of a standard Swing JList component, use JBList as drop-in replacement. JBList supports the following additional features on top of JList:

  • Drawing a tooltip with complete text of an item if the item doesn't fit into the list box width.

  • Drawing a gray text message in the middle of the list box when it contains no items. The text can be customized by calling getEmptyText().setText().

  • Drawing a busy icon in the top right corner of the list box to indicate that a background operation is being performed. This can be enabled by calling setPaintBusy().

Similarly, Tree provides a replacement for the standard Swing JTree. In addition to the features of JBList, it supports wide selection painting (Mac style) and auto-scroll on drag & drop.

ColoredListCellRenderer and ColoredTreeCellRenderer

To customize the presentation of items in a list box or a tree, use ColoredListCellRenderer or ColoredTreeCellRenderer as the cell renderer. With these classes, you can compose the presentation out of multiple text fragments with different attributes by calling append() and set an optional icon for the item by calling setIcon(). The renderer automatically takes care of setting the correct text color for selected items and of many other platform-specific rendering details.

ListSpeedSearch and TreeSpeedSearch

To facilitate keyboard-based selection of items in a list box or a tree, install a speed search handler on it using the ListSpeedSearch and TreeSpeedSearch. This can be done simply by calling new ListSpeedSearch(list) or new TreeSpeedSearch(tree). To customize the text which is used to locate the element, override the getElementText() method. Alternatively, you can pass a function to convert items to strings. A function needs to be passed as elementTextDelegate to the ListSpeedSearch constructor or as toString to the TreeSpeedSearch constructor.

ToolbarDecorator

A very common task in plugin development is showing a list or a tree where the user is allowed to add, remove, edit or reorder the items. The implementation of this task is greatly facilitated by ToolbarDecorator. This class provides a toolbar with actions on items and automatically enables drag & drop reordering of items in list boxes if supported by the underlying list model. The position of the toolbar above or below the list depends on the platform under which the IDE is running.

To use a toolbar decorator:

  • To support removing and reordering of items in a list box, make sure the list model implements EditableModel. CollectionListModel is a handy model class that implements this interface.

  • Call ToolbarDecorator.createDecorator() to create a decorator instance.

  • To support adding and/or removing items, call setAddAction() and/or setRemoveAction().

  • To add other buttons in addition to the standard ones, call addExtraAction() or setActionGroup().

  • Call createPanel() and add the component it returns to the panel.

10 November 2026