As a follow up to the previous post that showed how LightBeam tool can be used to analyze the performance of various core and third-party Swing look-and-feels, today i’m going to answer Luke’s question in the comments section and compare the performance of the core Substance skins.
The table below lists all available core Substance skins, and three numbers for each skin. The first number is the average time to complete a static performance scenario (rendering a bunch of controls to an offscreen image). The second number is the heap size after the static performance scenarios have been completed. The third number is the total time to run all dynamic performance scenarios (the list can be found in the PDF report or in the source code).

There is a simple explanation why Magma, Office 2007 family and Raven family have 25-45% worse dynamic performance than the rest – they use watermarks. I have already mentioned that this has been identified as the biggest performance obstacle during the performance tuning of version 5.0dev, and the skins that used the simple translucent-fill watermark do not use any watermark at all. The selected skins mentioned above are still using non-null watermarks to provide better visuals. You can extend these skins and set the watermark field to null in the constructor to get better performance (but less distinct visuals).
As you can see, there are minimal differences in the rest of the skins, even though they use different button shapers and painters. The core button shapers and painters have been improved to provide uniform performance so that you don’t have to sacrifice the visuals for the performance (except, once again, the watermarks).
If you do find that your custom skin has distinctly different results under different painters, i would be very interested in hearing about this in the project forums, mailing lists or a private e-mail.
Here are some Swing links that you might have missed during this week:
- Jan Erik Paulsen experiments with the new functionality of shaped and translucent windows in 6u10. The screenshots are impressive, and he is correctly pointing out two main deficiencies of the current (semi-private) API. The first is that you need to attach a listener to re-compute the window shape on window resize, and the second is lack of auto soft-clipping on the window shape outline.
- Jan Haderka has announced release 0.9.3 of SwingX. The release notes are available as well, and my only wish is that the official 1.0 release will be before the project turns four years old (next March).
- Dave Gilbert has announced release 1.0.10 of his JFreeChart library.
- Gunnar Sletta writes about release 4.4.0 of Qt Jambi, a Java port of cross-platform Qt client application framework. In addition to supporting all the new Qt features, like Phonon, Webkit, Widgets in Graphics View, XQuery and Qt Concurrent, it also has an improved deployment system, JDBC support and a compile-time checked signal-slot approach.
- Artem Ananiev solicits feedback on the forthcoming JWebPane component. This is a little bit problematic without any kind of downloadable content and no (even preliminary) Javadocs of the current API. Collin Fagan (aberrant) has a few interesting requests in the comments section.
- Jebgeni Kabanov has a screencast on changing the source code of a running Swing application with JavaRebel. Looking at the screencast (is there supposed to be sound), it doesn’t look overly impressive. Most of the changed functionality is available only in a new instance of a form (not in the running ones), and there’s even a glimpse into an exception during the last few seconds of the clip (look in the background Eclipse).
- Andrew Sazonov has a nice utility class for scheduling a delayed invocation of an action listener. This is useful for delaying updating the detail pane as the user scrolls through the master table, or preventing highly dynamic updates of status strings in a progress indicator.
- Finally, there is a lot of interest generated in Greg Brown‘s entry on Pivot, a framework for building cross-platform applications to be deployed on both web and desktop. I concur with Greg that building a new framework on top of Swing and exposing the underlying Swing components is not the best approach, and Pivot builds on top of Java2D instead. There is an interesting comment on Ben Galbraith‘s entry on Pivot that highlights the current trend in RIA toolkits (AIR / Silverlight) – audio / video, animations and skinning.
Here are some Swing links that you might have missed during this week:
- Synthetica look-and-feel has released version 2.7.0 and 2.7.1. No new skins have been added, but there are some new features and bug fixes.
- Swing has aged remarkably well considering its long history and imposed rules of preserving backwards compatibility. However, there are some trends in modern UI design that need some special handling in the application code, and Ken Orr shows how to address a common problem with tree renderers – making them fill the entire width of the row.
- Phoenix addresses a few other shortcomings of Swing components, showing how to provide continuation tooltips on trees and lists, wider and resizable popup windows in comboboxes and more.
- Tim Boudreau announces the availability of a pure tree table implementation available as a standalone module in NetBeans. I have seen a few such implementations, and they usually involve using an entire tree as the rubberstamp renderer for the tree column, translating and clipping the tree to show only the relevant part for each row. This presents significant maintenance problems in passing the events and having look-and-feel consistent animation events. Looks like Tim and Standa Aubrecht have been able to solve these problems. Geertjan Wielenga has a tutorial on how to use this tree table to show information on the file system.
- Collin Fagan continues working on the Swing tutorials and this week he has code samples for trees and borders.
- Alex Potochkin has announced release 3.0 of his JXLayer project. This is one of my favorite third-party additions to Swing, and it’s great to see that it is continuously improving. There is a brand new forum on java.net where you can ask questions on JXLayer, and i have found Alex to be extremely quick to respond and cooperative to address feature requests. We have also updated the Rainbow project to use the latest release of the library.
- David Qiao has posted slides and demo source code for his JavaOne BoF session on working around Swing bugs.
- Anthoney Scotney has announced release 4.2 of WebRenderer Swing edition, a browser SDK based on Firefox 2. The decision to base the code on Firefox is interesting, especially in light of other vendors (such as TrollTech and Sun) deciding to use the competing WebKit library. Firefox 3 is about to be released (perhaps sometime this week), and it would be interestingto see how quicky WebRenderer will switch. The performance improvements in Firefox 3, especially for JavaScript-heavy sites, are quite impressive.
- Joe Conti has created a static analysis tool to detect EDT violations at compilation time. The CheckThread project requires annotating your methods with the name of the intended runtime thread, and then checks to see whether there are any clashes between methods.
- Detangler is another tool that aims to detect Swing threading problems. It attaches to your application running in debugging mode and shows thread-related bugs that cause visual artifacts, gray windows, deadlocks and slow listeners that cause frozen UIs.
- Vaibhav Choudhary proposes a tool that will convert existing Swing applications to JavaFX. I’m not sure if the comparison with GWT as savior to writing AJAX applications is relevant, but from my experience automated conversion from one language to another never results in clean and readable code. There are just too many small differences between any two given languages, and you either decide not to support this (requiring large amount of manual work for any nontrivial app), or end up with an inordinate amount of generated code that doesn’t look anything like the best practices for the target language.
- Finally, Josh Reed has been experimenting with Groovy’s GraphicsBuilder, and he is very impressed.
A considerable part of the new skinning layer of Substance is geared towards enabling writing Swing applications that have UI capabilities of this WPF application designed by frog studio (mentioned a few months ago on this blog):

The required changes have slowly sipped into releases 4.2 and 4.3 of Substance, but were limited due to maintaining as much backwards compatibility as possible. However, the old skinning / theming layer was not up to the challenge, especially considering its deficiencies in handling mixed light / dark skins. This layer has been completely rewritten in version 5.0 (currently under development) and it is now possible to use different skins for different top-level windows (such as frames and dialogs).
To specify a custom skin for the specific top-level window, use the SubstanceLookAndFeel.SKIN_PROPERTY client property and set it on the root pane of that window. To get the skin of the specific control (to provide custom painting that is consistent with how Substance paints core and third-party Swing components), use the SubstanceLookAndFeel.getCurrentSkin(Component) API.
Here is a screenshot that shows an application with twelve top-level frames, each using its own skin (click for the fullsize version):

Note that applications using a single global skin do not incur performance overhead. Applications that use per-window skins do not incur performance overhead as well, but the memory consumption will be higher due to a larger number of cached images.
You’re more than welcome to test the latest development drop of Substance 5 and report any bugs (visual or exceptions) to the project mailing lists, forums on in a private e-mail.