Reputation: 1339
I'm new to programming, but I'm preparing to write a Java program. As I'm planning it, I'm trying to find the right GUI for it. I found this page with GUI options. I have two questions:
Upvotes: 2
Views: 12441
Reputation: 30014
Ignoring the pro/con of choosing a look and feel (LAF), I'll add some of my experience which using them...
If you're using a third-party/cots componentslibrary (JIDE, SwingLabs/SwingX, etc.) you will have problems as UI classes won't always exist or be up to date with all of the LAFs. JIDE supports a few external LAFs (Alloy and Synthetica). Some LAFs also offer support for widgets; Substance supports some of JIDE and SwingX. The end result is an application that is partially skinned. Not pretty. Make sure your LAF supports all of you components. If you're pure Swing/AWT, no problems.
In light of this, we use Alloy for JIDE support, considering moving to Synthetica. We would love to use Substance, but it doesn't have any JIDE support.
Upvotes: 1
Reputation: 88796
Building on what Uri said, you may want to stick with one of the more well-known look and feels.
If you use Swing, you may want to look into using the Nimbus look and feel... it's included with Java 6u10 and newer. Nimbus is built on the Synth framework included with Java 5 and newer.
Of course, if the end user is using a lower version, it will throw an UnsupportedLookAndFeelException and default to whatever the JVM default is (usually the Metal/Ocean (cross-platform) theme).
As a side note, if you use Swing, you can switch which look and feel is being used on the fly. You just have to call
// "lnfName" is the look and feel name.
// "frame" is the window's JFrame.
// A try/catch block is omitted here.
UIManager.setLookAndFeel(lnfName);
SwingUtilities.updateComponentTreeUI(frame);
frame.pack();
Upvotes: 3
Reputation: 11592
Changing the look and feel of a program is as simple as:
UIManager.setLookAndFeel("fully qualified name of look and feel");
before any GUI-creating code has been created. So you can easily create all your GUI with your GUI builder and then simply call this at the start of your program.
(Note that some look and feels, like Substance, are very strict when it comes to threading issues, so you better make sure that all your GUI code is run from the event dispatching thread.)
As a suggestion, two very good looking (and professional looking enough) look and feels in my opinion are Substance and also Nimbus which will ship with later releases of the JRE as the default look-N-feel (at least that's the plan) and which can be downloaded separately from java.net.
So if you opt for Nimbus the code would be:
UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
And one example of Substance (Substance has many skins and themes, if you want to know more read their documentation in their site) would be:
UIManager.setLookAndFeel(new org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel());
Also note that you can use the cross platform skin (Metal) like this:
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
And finally if you are on windows you can use the system look and feel like this:
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
Upvotes: 9
Reputation: 89749
Generally speaking, third-party GUI libraries with "look and feel" are not very popular, which is possibly an indication of their quality.
Standard GUI libraries are inherently very complex, and while they support some look and feel tweaking, the tweaks are often minor or constrained.
I would recommend sticking to Swing or SWT, and seeing what you can do with their look and feel mechanism, but don't expect miracles.
Upvotes: 0