Wednesday, March 09, 2005

Installed Look and Feels

"WYSIWIG: What you see is fake hair."

The appearance and behavior of a GUI is called "look and feel". Playing around with Swing (Java SDK 1.4.2-beta "Mantis"), you would perhaps wonder what look and feels are installed.

Because Java is platform independent, you should always find the installed look and feels before letting the user select look and feel.

Create a JButton with NetBeans IDE, called getInstalledLookAndFeels, and add the following code.

    private void getInstalledLookAndFeelsActionPerformed(java.awt.event.ActionEvent evt) {
        // Add your handling code here:
        UIManager.LookAndFeelInfo[] lookAndFeelInfo = UIManager.getInstalledLookAndFeels();
        for (int i = 0; i < lookAndFeelInfo.length; i++) {
                System.out.println(lookAndFeelInfo[i].getName() + ", " + 

Under Linux, Swing reports the following installed look and feels:

Metal, javax.swing.plaf.metal.MetalLookAndFeel

Seems like Java SDK 1.4.2-beta missed the new look and feel called GTK+ with the class name "". Also, Java SDK 1.4.2-beta reports the bogus look and feel for Microsoft Windows with the class name "". By the way, this is Bug Id 4843282 in Suns bug database.

No comments: