Substance theme pack updated

January 4th, 2008

In addition to about twenty core Substance themes, the theme pack plugin provides even more themes to create a unique look for your Swing applications. When you put the binary plugin in the classpath, the additional themes become available in the getAllThemes() API, and you can use them just like any other core theme.

As part of updating the licensing headers to 2008, i’ve also updated the screenshots of extra themes to reflect the latest visuals of Substance. Here are some of my favourites:

Belize

Brick Wall

Fauve Mauve

Mahogany

Orchid Alloy

Yellow Marine

The subject of native text rendering in Swing applications has been introduced on this blog about six weeks ago, and I already described some of the implementation details. The devil is, of course, in details (unless you’re working on whizzy demoes), and i’ve spent the last month working on all the issues mentioned in the original post. This post addresses the functionality that has been missing, talks about the unsupported cases and links to a WebStart demo (at the end).

Easier deployment and support for WebStart environment

With migration to release 3.3.0 of SWT and valuable help from the SWT dev mailing list (thanks, Dave), it is now much easier to configure Bramble and SWT. Browse to the SWT main page, download the relevant distribution (Bramble distribution bundles the Windows version) and add the swt.jar to your classpath. That’s it – no more need to muck with the java.library.path VM flag and no need to extract the native libraries from the SWT jar (like was the case in 3.2.1).

To use the native text rendering in your WebStart application, take the latest substance-bramble.jar and the matching swt.jar, sign them and you’re ready to go. Note that if you’re using the jar from Eclipse itself, it’s already signed. Although it’s possible to use jars signed by different parties, I had security access exceptions on using the SWT jar from Eclipse. If you use the jar from the SWT main page, it works flawlessly (see the WebStart link at the end of this entry). If you need your application targeting multiple platforms, you’ll need to bundle the matching SWT jars and use the resources JNLP tag accordingly.

Support for all core Swing components

The latest binary and source drops of Bramble plugin provide support for all core Swing components with the following exclusions:

  • Non-plain text components, including text panes and editor panes.
  • HTML text.
  • Titled borders.

The text on all these components (including HTML) is painted with the default core AWT text font rasterizer. The latest plugin version also provides support for painting rotated (vertical) texts which are used on vertical progress bars and sliders (with labels). Interestingly enough, the rotation transformations in AWT and SWT are different (rotation angles have opposite values, and hence the translation offsets are different as well).

Support for SwingX components

This will be done in the next Substance release. As a proof of concept, the latest SwingX plugin provides native text painting for the status bar components. As in the case above, all other SwingX components use the core AWT text font rasterizer.

Support for additional operating systems

While the primary target of Bramble plugin is Windows Vista (and the inadequate AWT rasterizing of the default “Segoe UI” font), this plugin is not Windows-specific. It has been successfully tested under Windows Vista, Windows XP, Windows 2003 and Ubuntu 7.10. If you encounter bugs (visual or exceptions) under other platforms (KDE, Mac and others which are supported by SWT), I would be very interested in hearing about it.

Incidentally, using the native text renderer can not only make the applications look better. The core AWT font rasterizer has its own bugs (as all software does). This bug report opened on Substance (under Ubuntu / Gnome) is caused by a bug in the default font rasterizer that fails on a specific non-Latin character (see the bug report for more details). Since this happens under the core GTK look-and-feel and Substance provides the platform-specific font policy lookup that is aligned with the GTK LAF font lookup, this bug is seen under Substance as well. While the visual quality of the AWT font rasterizer on “DejaVu Sans” is very close to the native text renderer and there isn’t much reason to bundle SWT and Bramble, at least in this case doing so makes the application run with no exceptions and look like it belongs to the specific desktop.

Under Windows Vista, the Bramble plugin will also instruct Substance to use “Segoe UI” font under JDK 5.0 as well. Unlike the AWT font rasterizer that did even worse job under JDK 5.0, the native text renderer doesn’t care. So, you don’t have to upgrade to JDK 6.0 to have your applications look good on Vista.

Demo

Clicking on the button below will launch the full Substance test application that uses Bramble plugin to render all the texts with the native renderer. Note that while the application itself is cross-platform, this specific JNLP file only uses Windows version of SWT (no need to leave comments that this specific JNLP doesn’t work on Ubuntu or Mac). It is signed since one of the tabs shows the file system tree. As you’ll see, the texts on the task panes (left hand side) do not have proper background – as mentioned earlier, full support for SwingX components will be added in the next release. So, click around and let me know if you see something fishy :)

You’re more than welcome to leave comments with your thoughts, suggestions and bug reports (but first make sure that you’ve read this entry in its entirety). The plugin is distributed under the Eclipse Public License (EPL). The release candidate is scheduled for January 21st, with the release scheduled for February 4th.

Here are some Swing links that you might have missed during this week:

  • Nazmul Idris has created a tutorial on SwingX painters. The painters generated quite a lot of heated discussion and development about half a year ago, and there were passionate talks about restructuring the entire Swing painting pipeline around the painters. It seems that once the big plan was shot down by the Swing team (and quite rightfully so since that would result in breaking a lot of existing code), no effort has been done to search for alternative ways to introduce painters into the core Swing library. The active development of SwingX painters seems to have died pretty much after that.
  • Mikhail Lapshin answers a question posted on Swing forum on how to create menus that pop up only on mouse click (and not on mouse over). While this might confuse a user (i’ve tried a few native Windows applications and they all pop up menus on mouse over), some applications can still find this technique very useful.
  • Eugene Kuleshov posts a riddle on achieving the specific layout with SWT, AWT or Swing. The simple answer is – do not use titled borders and nested panels. This has been long considered a bad design decision that adds unnecessary noise to the form. Use white space, tabbing and separators to create visual groups.
  • Jan Haderka continues working on various parts of SwingX, and this time he presents his improvements on BusyPainter and JXBusyLabel. The demo comes with a very useful option to play with the settings and then generate the matching code (copied to the clipboard). My only recommendation would be to drop some of the irrelevant features (such as trajectory shifts and dimensions) and look at some other ways to convey infinite progress (warning, high visual overload :) )
  • Andres Almiray wraps up version 0.4.3 of GraphicsBuilder, showing its many new features (the multipaints example looks very good) and hints at the forthcoming support for SVG in version 0.4.4.

Here are some Swing links that you might have missed during this week:

  • Laird Nelson dives into intricacies of keyboard shortcuts, actions maps and focus state inheritance to show you how to make all dialogs and frames to be disposed on pressing the ESC key. Hopefully this will be one of many entries in this series, and the Bricks project will live long and prosper :)
  • Angry Mongoose laments the lack of Swing best practices. It is indeed the unfortunate reality that Swing developers live in. The wealth of well-compiled, updated and comprehensive information available to the consumers of alternative desktop technologies (such as WPF or Flex / Flash / Apollo) is astounding, compared to what is produced by training / marketing / evangelizing departments behind Swing (if any).
  • Chiral Software brings the power of of JBoss, JSF, iText and JFreeChart together, showing how to create PDFs with rendered Swing components. The first part lays the groundwork, and the second part shows how to create vector-based charts.
  • Sergey Malenkov is working on enhancements to the core JColorChooser component, and is asking for the community to step up and weigh in on the design. Unfortunately, the actual designers do not read programmers’ blogs, so this is most probably a lost call. Hopefully, there are some professional designers working on the JavaFX design tool. If it’s designed by the programmers, the end result will not move the designers away from the competing tools.
  • Tim Dalton continues his explorations with Scala, using Swing as the “native” UI toolkit. This time, he takes a look at the newly announced Scene Graph library. While the first example shows just a few shapes and a translucent button, the second one is a little more interesting. Building on his previous example, he shows a rotatable calculator. It would be extremely interesting to know whether the rotated Swing controls continue responding correctly to the mouse events, something that Alex has had quite a few problems with.
  • Andres Almiray continues beefing up the Groovy bindings for Swing, adding more capabilities to the GraphicsBuilder (here, here and here), and showing a nice example of the Linux penguin mascot done in Groovy.