Java Swing API renders the GUI in the Java Look and Feel but at times we want it to use a certain look and feel like Motif or Windows or want to change the look and feel dynamically from the application itself based on user selection etc. It's very easy to change the l&f of the application using the UIManager. This is generally done at the startup of the application by using the setLookAndFeel method. The following code snippet shows how to do the same.

package com.livrona.snippets.gui;

import java.awt.BorderLayout;
import java.awt.Label;

import javax.swing.JFrame;
import javax.swing.UIManager;

/**
 * This snippet shows how to changes the look an feel 
 * of the gui application.
 * 
 * @author mvohra
 * 
 */
public class LookAndFeel {

	/**
	 * Main Method
	 * 
	 * @param args
	 */
	public static void main(String args[]) {

		try {

			// use one of the following method based on the desired look& feel

			// set the look & feel based on OS itself
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

			// java metal look and feel works across platform
			UIManager.setLookAndFeel(UIManager
					.getCrossPlatformLookAndFeelClassName());

			// set the Motif look and feel
			String motifClassName = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
			UIManager.setLookAndFeel(motifClassName);

			// set the look & feel based on
		} catch (Exception e) {
			System.out.println("Error failed to set the Look & Feel"
					+ e.getMessage());
			e.printStackTrace();
		}

		// rest of the gui code like creating frame etc. goes here
		// 1. Create the frame.
		JFrame frame = new JFrame("FrameDemo");

		// 2. Optional: What happens when the frame closes?
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		// 3. Create components and put them in the frame.
		// ...create emptyLabel...
		frame.getContentPane().add(new Label("See the Look and Feel"),
				BorderLayout.CENTER);

		// 4. Size the frame.
		frame.pack();

		// 5. Show it.
		frame.setVisible(true);

	}
}