RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Fatten Up Your Java UIs with JGoodies

Think you can get your end users to exclaim: "My! What beautiful native-looking Windows apps you build in Java"? A basketful of JGoodies is all you need.

erhaps the single biggest challenge in writing Java applications is dealing with UI issues. Regardless of the application's power and flexibility, people will always want it to look familiar—to look like a Windows application. With JGoodies you can give them what they want, and a whole lot more besides!

Java has never really been a competitor for premium desktop systems. Its very nature being that of write once, run anywhere leads to a lowest common denominator approach. For example, some operating systems support mice with three buttons, some with two and some with only one. For a Java application to run 'everywhere,' it can only support a single mouse button. The extra button functionality that could be available on other systems is lost. There are other user interface widgets and design patterns that are similarly unexploitable, and the ultimate effect is that Java never really penetrated the applications market. Visual Basic reined supreme.

However, when it comes to middleware or serverware, Java provides an amazing proposition. The same code runs your transactions, your analytics, your business apps regardless of the operating platform! Is Solaris too expensive? Replace it with Microsoft. Your software will still work. Is Microsoft too unstable? Replace it with Linux. Your software will still work!

However, the Java-based desktop may be making a comeback. Some of the pending APIs from Sun as well as innovations coming out of the open-source community are redrawing the map and will change the perception of how Java works in the desktop application environment.

For example, BEA's Weblogic Workshop 8.1, sports a truly beautiful user interface using Java. Oracle and others are also developing Java IDEs with great-looking Java UIs. One of these transformative look-and-feel APIs is JGoodies. JGoodies is freely available and can be used in your own applications. By browsing the JGoodies site at http://www.jgoodies.com, you'll see examples of user interfaces built using the JGoodies API. One example is shown in Figure 1, below.

Figure 1. Previewing the Goodies: A sample user interface made using the JGoodies API is shown.
Unpacking the JGoodies
To get started using JGoodies, download the Look and Feel and the Forms APIs and then unzip the files to a directory on your hard drive (e.g. c:\jgoodieslooks). The result should look like Figure 2.

Figure 2. Unpack the Goodies: This is what your unzipped JGoodies directory structure should look like before you begin developing.
For the purposes of this article you will only need the Look and Feel API, but in order to compile and test the demo application from the Look and Feel API, you will need the JAR files that come with the Forms API as well.

There are two ways to work with the JGoodies Look and Feel API:

  • You can refer directly to JGoodies classes, which is done at compile time. This is the preferred method and generally less prone to errors than indirect references. It requires you to import the precompiled classes to your project, so you should only use it if you know that the classes will be present at runtime.
      try {
           UIManager.setLookAndFeel(new Plastic3DLookAndFeel());
       } catch (Exception e) {}
  • Indirect reference using class names. If you are not sure whether the classes will by available at runtime you can reference them in this manner.
    try {
       } catch (Exception e) {}

The class must be one of the following:

  • com.jgoodies.plaf.windows.ExtWindowsLookAndFeel
  • com.jgoodies.plaf.plastic.PlasticLookAndFeel
  • com.jgoodies.plaf.plastic.Plastic3DLookAndFeel
  • com.jgoodies.plaf.plastic.PlasticXPLookAndFeel
The Plastic themes use a default color scheme that is appropriate for your operating system. However a method setMyCurrentTheme is provided that allows you to override this. For example:

	PlasticLookAndFeel.setMyCurrentTheme(new DesertBlue());
Here, DesertBlue() is a color theme specified in the com.jgoodies.plaf.plastic.theme package.

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date