Project LightBeam was created a few months ago to assist Swing look-and-feel developers to reliably measure performance aspects of their libraries. LightBeam has a collection of static and dynamic scenarios that test different aspects of painting and tracking changes on core Swing components making it easier to identify performance bottlenecks and helping prevent performance regressions after introducing new features. LightBeam has been extensively used throughout the development cycle of version 5.0 of Substance look-and-feel to bring it in line with other core and active third-party look-and-feels.

An unexpected and welcome usage of LightBeam comes from the XRender Pipeline project that aims to create a new Java2D rendering pipeline based upong the X11 XRender extension. This project is part of OpenJDK Community Innovators’ Challenge that has reached the submission deadline yesterday, and is lead by Clemens Eisserer. The benchmark page of XRender project uses two third-party open-source benchmarking suites – MigLayout swing benchmark and LightBeam. Here is one of the benchmark charts comparing the performance of X11 and XRender pipelines under LightBeam (unfortunately misspelled):

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

  • Jon Lipsky is back from a two-year long blogging hiatus and he writes about extending the RelativeLayout from James Elliott’s 2002 article.
  • Santhosh Kumar is back as well (he’s not been blogging about Swing since last August), and this time he brings the auto-snap split pane divider. The solution is very simple, but i’m not sure of the usability of this particular feature. In the past, i always found the different auto-snap behaviors (such as windows in desktop managers or connectors in Visio) to stand in my way most of the time, leading me to fight with the UI. On the other hand, auto-snap in sliders is quite a useful features to restrict the input domain to a small discrete subset.
  • JavaSwing.net continues its series of tutorials on Swing text components, and this time they write an introduction to working with JFormattedTextField component.
  • Gregg Bolinger has an implementation of application wide hotkeys. It uses a custom EventQueue that inspects all KeyEvents and consumes those keystrokes that it sees as the custom hotkey launchers. If you decide to follow this route, be sure to read Hans Muller‘s post on the mailing list of AppFramework project from last October:

The downside is that I’ve spoken with the AWT technical lead and he’s suggested that using EventQueue.push() is deadlock-prone. That is, the area of code that deals with EventQueues is quite complex and there may be unknown bugs that could cause deadlocks.

  • And finally, Ken Orr tracks an interesting problem of providing different visuals for controls in active and inactive windows. His solutions include checking Window.isFocused in various painting methods (such as JPanel.getBorder and JLabel.getForeground) and tracking the changes to “Frame.active” client property.

My number one wish for Java desktop for this year was cross-platform support for H.264 and FLV formats. Today has marked a first (and hopefully not last) step towards playing video content in Swing application – Java Media Components which is a part of JavaFX preview SDK.

Here is what you need to do to use JMC in your Swing application:

  1. Download and install the JavaFX preview SDK. The rest of the steps assumes that the SDK has been installed in the C:|Program Files/JavaFX/javafx-sdk1.0pre1 folder.
  2. Add the lib/jmc.jar to the classpath of your project.
  3. Use one of the examples from the JavaOne presentation on JMC (see full code below).
  4. Run the application with the following VM flag: -Djava.library.path=”C:/Program Files/JavaFX/javafx-sdk1.0pre1/lib”

I have tested the current JMC drop on the following formats:

  • Flash content – FLV and SWF files. While the regular content plays correctly, i have not been able to interact with the content of an interactive SWF file.
  • Container formats – AVI, MPG, MKV.

I have not been able to play the MOV files (H.264). Hopefully this will be addressed in the future releases of JMC, even before providing a cross-platform codec from On2.

Here is a sample screenshot of JMC playing an MKV file on a frame with translucent reflection (click to see the full size version):

JMC playing an MKV file in a frame with translucent reflection
JMC playing an MKV file in a frame with translucent reflection

MKV is a popular container format for video / audio content, and it is used by Azureus Vuze application. The screenshot above shows the trailer of “Watchmen” movie, and while Azureus uses the native executable for MPlayer to play these files, JMC goes a step further and exposes a Java API layer to Swing applications. You can find the full source code behind the screenshot at this location.

< Prev Next >