Resolution independent Swing, part III – miscellania

October 1st, 2007 | 3 Comments »

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.


Related posts:

  1. Resolution independent Swing, part II – borders The first part of this series showed that it takes a little more than vector-based...
  2. Resolution independent Swing, part I – alignment and baseline I first touched on the subject of resolution-independent Swing UIs and automatic support for high-DPI...
  3. JavaOne session on high resolution monitors I have the honor to be joined by Mike Swingler (Swing / AWT lead for...
  4. Release miscellania In addition to releasing Trident 1.2 and Substance 6.0, today i have released the following:...


3 Comments on “Resolution independent Swing, part III – miscellania”

  1. 1 Greg Tangey said at 5:39 pm on October 2nd, 2007:

    Hey Kirill

    I’m really liking this series of articles, keep them up. On a side note, substance has come a long way since it’s inception and i’m proud to say i now user over most other look and feels. You should be real happy with what you’ve created/are creating here as it’s definitely come a long way visually to be more eye-pleasing.

  2. 2 Kirill Grouchnikov said at 5:46 pm on October 2nd, 2007:

    Greg,

    Thanks for the kind words. I should also thank all the users, bug reporters and the competition (Looks, Alloy, Synthetica and lately Nimbus) for making me go on :)

  3. 3 AC said at 5:31 am on October 3rd, 2007:

    Wouldn’t the approach taken by Piccolo/Jazz ZUI toolkit (http://www.cs.umd.edu/hcil/jazz/) provide resolution independence as well?

    There is an extension that enables the use of arbitrary Swing components as zoomable elements in Piccolo:
    http://mailman.cs.umd.edu/pipermail/piccolo-chat/2005/000787.html
    http://source.concord.org/maven2/site/cck/apidocs/edu/umd/cs/piccolox/pswing/PSwing.html

    It could be useful in other ways as well since JavaFX seems to be built around something similar:
    http://blogs.sun.com/chrisoliver/entry/more_about_f3