# Java Notes

# Look and Feel

## Summary

- Look and Feel is the term for the general appearance of GUI components. Java allows you to change it.
- System vs portable L&F. The default L&F is the Java portable look and feel. A popular choice is to use the current system look and feel (eg, Windows or Macintosh).
- Non-standard. You can use independent L&Fs to give the user a particular experience. See below.
- Start of main(). If you set the look and feel, put it as the first thing in main().

## Default cross-platform Look and Feel

Java cross-platform Look & Feel is the default, so you don't have to set it. This is the most portable. |

## System Look and Feel

Some think the user experience is better when a program matches the system L&F, eg, on Windows the program has a Windows L&F (as in the example below), on the Macintosh it will use the standard Macintosh L&F. The only change to the code that produced the sample above was to set the L&F. The components have a different shape, size, and appearance. |

Here's how to use the System L&F. Be sure it's the first thing in main.

    public static void main(String[] args) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception unused) {
            ; // Ignore exception because we can't do anything.  Will use default.
        }
        . . .

## Examples of other L&Fs

Alpha software. The Napkin L&F makes software look like it's under construction, which prevents a slick looking interface from making your customer think the program is almost finished. |

After downloading the appropriate .jar file and making sure it's in the classpath, set it as follows.

    public static void main(String[] args) {
        try {
            UIManager.setLookAndFeel(new net.sourceforge.napkinlaf.NapkinLookAndFeel());
        } catch (Exception unused) {
            ; // Ignore exception because we can't do anything.  Will use default.
        }
        . . .

Alternate look. You simply might prefer a different look. For example, here's Liquid L&F. |

## Where to find and how to install other Look and Feels

Finding. You can use Google to find L&Fs, but www.javootoo.com is a good place to start. It has samples and links to a number of free and for-pay custom L&Fs.

Installing other L&Fs is done by putting the `.jar` file (eg, `napkinlaf.jar`) in the CLASSPATH, and make the appropriate call as above.

NetBeans installation is relatively easily done by a right-click on the project, selecting Properties, click on Libraries and then Add JAR/Folder and select the L&F .jar file.