The latest weekly drop of JDK 7 (b57) has finally exposed the functionality of translucent and shaped windows as publicly supported APIs on the java.awt.Window class. Bug 6802853 has tracked the progress of exposing these APIs previously available in 6u10+ in the internal com.sun.awt.AWTUtilities class, and it’s time to update the examples to use the new public APIs.

To recap, here are the previous entries that used the AWTUtilities class:

All the source files referenced in these examples have been updated to use the new Window APIs, and here is a brief overview of the relevant API signatures:

  • AWTUtilities.isTranslucencySupported(Translucency) is now GraphicsDevice.isWindowTranslucencySupported(WindowTranslucency).
  • AWTUtilities.isTranslucencyCapable(GraphicsConfiguration) is now GraphicsConfiguration.isTranslucencyCapable().
  • AWTUtilities.setWindowShape(Window, Shape) is now Window.setShape(Shape).
  • AWTUtilities.setWindowOpacity(Window, float) is now Window.setOpacity(float).
  • AWTUtilities.setWindowOpaque(boolean) is superceded by Window.setBackground(Color). Passing the new Color(0, 0, 0, 0) achieves the old effect of installing per-pixel translucency.

You can see the Javadocs of the new Window methods in the corresponding Mercurial diff, or in the source archive bundled with the b57 installer.

Note that the com.sun.awt.AWTUtilities class is still there, and calling its API methods still produces the correct visuals. A quick look at the implementation reveals that the AWTUtilities methods do not (yet) go directly to the new Window methods, perhaps converging deeper in the AWT internals.

Google’s Java editions

April 18th, 2009

Following the announcement of Google App Engine for Java, it’s interesting to see how Sun and Google differ in their analysis of market trends. Traditionally, Sun has three main “versions” of Java:

  • Java Standard Edition (SE) for desktop applications
  • Java Enterprise Edition (EE) for server side
  • Java Mobile Edition (ME) for phones

With JavaFX, the new (and perhaps belatedly rediscovered) focus on client side market has three versions:

  • Desktop profile
  • Mobile profile
  • TV profile

with a common profile that aims to write an application once, and have it run on all three types of displays – and the history will tell how well that will be supported and used in practice.

What about Google? This is how i see it:

  • GWT is Java Web Edition (WE)
  • Android is Java Device Edition (DE)
  • App Engine is Java Cloud Edition (CE)

and no stated goal (at least yet) to provide a common edition for GWT and Android.

A few hours ago an interesting changelist has made its way into the JDK 7 Swing branch. It definitely looks like the Nimbus designer will be available as part of JDK 7.

Unfortunately, it does look like this changelist does not contain all the files that are part of Nimbus designer (see below for the walkthrough), but hopefully this will be amended in the following days. In the meanwhile, here is what i’ve been able to do:

  • Click on the zip link on the changelist page and extract the contents of the zip file. I’ve saved it in the C:\JTools\jdk7-src folder.
  • Create a new Eclipse project. Point to C:\JTools\jdk7-src\jdk-c5cd40f1f596\make\tools\swing-nimbus\classes as source, and add all the jars in C:\JTools\jdk7-src\jdk-c5cd40f1f596\make\tools\swing-nimbus\libs as external jars.

As i said before, it looks like the changelist is not complete, and i haven’t been able to find the main class to run the designer itself. However, you can run the partial generation of Nimbus painters to get the feel of how that phase is working. Here are the steps:

Run the org.jibx.binding.Compile class passing the following two program arguments:

  • C:\JTools\jdk7-src\jdk-c5cd40f1f596\make\tools\swing-nimbus\classes\org\jdesktop\swingx\designer\Designer.jibx.xml
  • C:\JTools\jdk7-src\jdk-c5cd40f1f596\make\tools\swing-nimbus\classes\org\jdesktop\synthdesigner\synthmodel\SynthModel.jibx.xml

Copy the three .template files from C:\JTools\jdk7-src\jdk-c5cd40f1f596\src\share\classes\javax\swing\plaf\nimbus to C:\JTools\jdk7-src\jdk-c5cd40f1f596\make\tools\swing-nimbus\classes\org\jdesktop\synthdesigner\generator\resources

Run the org.jdesktop.synthdesigner.generator.Generator class passing the following arguments:

  • -full false
  • -skinFile C:\JTools\jdk7-src\jdk-c5cd40f1f596\src\share\classes\javax\swing\plaf\nimbus\skin.laf
  • -srcDir c:\temp\nimbus
  • -buildDir c:\temp\nimbus
  • -packagePrefix org.nimbus
  • -lafName Nimbus

At this point, the c:\temp\nimbus should have the generated painter classes. Note that if you pass the -full true, the generation will fail since some of the template files (such as LookAndFeel.template) are not part of this changelist.

    The third volume of Substance sightings series highlights three gaming applications powered by Substance look-and-feel. The purpose of this series is to highlight the capabilities that Substance brings to Swing applications, and you can visit the first volume published in August ’07 that featured four Swing media-oriented applications, and the second volume published in April ’08 that showcased three open-source audio players.

    The first application is WarForge which is a template builder for Warhammer Online. Here is a screenshot of WarForge under the dark Magma skin (click to see full-screen image):

    The next application is OGame Automizer – an automated bot for the OGame intergalactic conquest online browser game. Here is a screenshot of WarForge under the Nebula skin (click to see full-screen image):

    The last game is the Darkside turn-based strategy game. Here is a screenshot of WarForge under the dark Raven Graphite Glass skin (click to see full-screen image):

    If you haven’t tried Substance in your application, you’re more than welcome to do so. The current stable release is 5.1, and the next 5.2 version is available in early development drops.