Lists, Tables, and Trees
Striped Background Style
Lists, tables, and trees all support an optional striped background style. The striped style
is selected by setting the appropriate client property (JList.style
,
JTable.style
, or JTree.style
) to the value striped
. See the note
below about cell renderer issues, which affect the ability to display a striped
background.
Additional steps may be needed to properly display a JTable using a striped background
in a space that is larger than the table itself. Normally, in that situation, it is
best if the stripes fill the space. However, because the stripes are painted by the
JTable, they will not extend beyond the bounds of the table, which by default are the bounds of
the table rows and columns. The solution is to enable automatic column resizing
(using setAutoResizeMode()
) and filling the viewport height (using setFillsViewportHeight()
).
In this situation, it may be useful to limit the width of individual columns by
disabling resizing (using setResizable()
)
or setting a maximum width (using setMaxWidth()
) on the
column. The combination of automatic column resizing and non-resizable or limited width columns
allows the table to extend beyond the columns, which enables the striped background to fill
the width of the space.
SideBar List and Tree Style
VAqua supports an optional sidebar style for lists and trees. This style mimics the style of the Finder sidebar.
The sidebar style
is selected by setting the client property JList.style
or JTree.style
to sideBar
. See the note
below about cell renderer issues, which affect the ability to display the sidebar
style.
Inset View Style
VAqua supports the inset view style introduced in macOS 11, in which the selection highlight
uses rounded corners.
The inset view style is used automatically for sidebar style lists and trees.
Otherwise, the inset view style is selected by
setting the appropriate client property (JList.viewStyle
,
JTable.viewStyle
, or JTree.viewStyle
) to the value inset
.
The inset view style requires adding margins to the container, which is supported
automatically on lists and trees, but not on tables. To use the inset view style with
a table requires an extended JTable
implementation JTableWithMargins
,
available in the VAquaClient library.
Filled Tree Cells
Normally, a tree cell renderer will be sized at the preferred size of the renderer component.
VAqua supports an option to expand tree cells to fill the remaining width of the row.
This option is selected by setting the client property JTree.isCellFilled
to (Boolean) true
.
This option does not currently affect the size of the cell editor.
Cell Renderer Issues
Several background styles supported by VAqua, including some default styles, require the willing or unwilling cooperation of the cell renderers to avoid painting over the style-created background (for example, the stripes of a striped style, the selected row background, or the sidebar custom background). In general, a cell renderer should avoid painting a background (a translucent background might be acceptable). In some cases, VAqua will override the cell renderer background color to force it to be consistent with the overall background. Direct use of the default cell renderers should work properly.