Just looking through some old code for a Java/Swing editor I started writing years ago, I saw this line of code that I added specifically for the Mac OS X platform:
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:
Note that the
setLookAndFeel method can throw an
UnsupportedLookAndFeelException exception that you should handle.
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:
Then use this code:
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() );