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

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

			// java metal look and feel works across platform

			// set the Motif look and feel
			String motifClassName = "";

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

		// 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?

		// 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.

		// 5. Show it.