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:
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());
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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With