October 1st, 2007

Resolution independent Swing, part III – miscellania

Continuing the series on the support for high-DPI monitors in Swing applications and having covered the big areas in the first two entries (alignment and borders), it’s time for miscellaneous stuff. There are quite a few less-defined areas that should be addressed by a look-and-feel that aims to provide complete high-DPI support. Let’s look at some of these.

The first one is linear elements, such as separators, titled borders and focus rings. Like the borders, these should be painted with a stroke width proportional to the default desktop font size and DPI settings (or the font size of the specific component). In addition to painting, these settings affect the preferred size and insets of the corresponding elements. Here is a screenshot of two titled borders under 22pt fonts:

In addition to titled borders, the look-and-feel should also scale such elements as focus ring stroke width, dash length and dash gap. This is illustrated in the next screenshot (second slider has the focus):

In this screenshot, you can also see an additional linear element – slider ticks. These are also scaled (length and thickness) with the font settings. Furthermore, the entire slider painting is scaled as well, including the track height, thumb icon, track border thickness and thumb icon thickness. All of these affect both the inner layout and the preferred size computations.

An additional area is cell renderers. There are quite a few of these on core Swing components, including lists, trees, tables and table headers. While some applications use custom renderers (which should be written to support high-DPI monitors), the look-and-feel is responsible for providing the default renderers. These should properly compute the insets and set the borders (for focus indication, for example). Here is a screenshot of a table under 22pt font:

As you can see, everything is scaled here, including the renderer insets, header renderer borders and table grid lines.

The areas mentioned in this entry are just a sample. There are many more, including vertical components (such as sliders and progress bars), menu items, right-to-left orientation.

All the screenshots in this entry have been taken under the latest 4.1dev drop of Substance (code-named Lima). It is scheduled to be released in mid-November, with a release candidate scheduled for late October. You’re more than welcome to download and play with the latest bits, as the development is going to move much slower towards the feature freeze in two weeks.