plaf

Java look and feel - how to use the native system look and feel

Question: How do I set my Java/Swing application to use the native look and feel of the platform it is running on?

Answer: Use the Java UIManager class to set the look and feel properly, like this:

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

Note that the setLookAndFeel method can throw an UnsupportedLookAndFeelException exception that you should handle.

 

Java Swing look and feel - How to use the default look and feel

Java Swing FAQ: How do I set my Java/Swing (GUI) application to use the default look and feel of the current system/platform?

In a Java / Swing application, to use the default look and feel of the current operating system (platform), first import the necessary class:

import javax.swing.UIManager;

Then use this code:

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

Java look and feel - How to use the "metal" look and feel

Java Swing FAQ: How do I set my Java look and feel to the "metal" look and feel?

To set your Java / Swing application to use the metal look and feel, first import the necessary classes:

import javax.swing.UIManager;
import javax.swing.plaf.metal.MetalLookAndFeel;

Then put this in your code:

UIManager.setLookAndFeel( new MetalLookAndFeel() );