New painter types in Substance

February 20th, 2008

About three months ago i wrote an overview of painters in Substance look-and-feel. Painters are one of the major building blocks of Substance, and over the last few releases they have been used extensively to provide consistent appearance to both core and third-party components. Unfortunately, the original painter design and responsibilities have not always stood the test of time, and one of the painters has grown significantly beyond its API. This has made the code more complicated, cryptic and in some cases, a pain to maintain. It applied not only to the internal code, but also to the external painter users (as outlined in the skinner primer).

Specifically, i am talking about title / header painters. Originally, the title painters were responsible for painting title panes of top-level windows (frames, dialogs), internal frames and desktop icons. Over the last few releases, they have evolved significantly to allow custom painting of other UI areas, such as menu bars, tool bars, task pane containers, status bars and others. As additional capabilities were added to the title painter API and implementation classes, it became clear that these no longer reflect the true usage – decoration painting. To this end, let me first introduce the new concept in Substance – decoration area type:

The <font color="darkblue">org.jvnet.substance.painter.decoration.DecorationAreaType </font>enum provides enumeration of available decoration area types. As a picture is worth a thousand words, the following screenshots illustrate the different decoration area types.

The following screenshot is the main Substance test application under the Business Black Steel skin (click to see full size version):

The next screenshot shows the title decoration area, which in this example includes the title pane of the main window:

The next screenshot shows the header decoration area, which in this example includes the menu bar of the main window:

The next screenshot shows the toolbar decoration area, which in this example includes the tool bar of the main window:

The next screenshot shows the general decoration area, which in this example includes the task pane container and status bar components from the SwingX suite:

Let’s go back to the original screenshot:

It illustrates that the specific skin assigns different color schemes to different decoration areas. The controls in those areas get the background and foreground colors based on their assigned color scheme (without any custom application code), thus creating visual distinction between different application areas.

In addition to the decoration painter, the latest development drop of version 4.3 (code-named Nairobi) introduces the new highlight painter API. The highlight painter is used to paint rollover and selection highlights on tables, trees, lists and menu items. In addition, it is used to paint highlights on third-party components, such as task pane container and month view in the SwingX suite.

For more information, please consult the following documentation:

If you switch to the latest 4.3dev binary drops, you might experience a few minor visual glitches. These will be addressed during the development cycle, but don’t hesitate to drop a mail or post a forum message if you find a regression. Also, if you were using the old title / header painter APIs or were providing a custom title / header painter in your application – first, apologies for breaking the binary compatibility, and second, i am here to help migrating your old code to the new painters.