Share this page 

Use any LookAndFeel on any plateformTag(s): Swing

There is some restriction to the usage of LookAndFeel when there are some copyright involved. For example, you can't activate the Mac LookAndFeel in a Windows environment.

The trick is to fool Swing by setting the property to a different value than real one to enable the use of "forbidden" LookAndFeel.

From the command line,
to activate Windows LookAndFeel on a non-Windows environment

java MySwingApp
to activate Mac LookAndFeel on a non-Mac environment
java MySwingApp
or you can do it in your source by doing something like:
Properties p = System.getProperties();
p.put("", "Mac");
NOTE: Current Swing release for Windows does not include the necessary classes for the Mac's LookAndFeel anymore.

It's not bad idea to set the look and feel to a known good value and then try the not-so-sure value.

try {
 // sure look and feel
 // not-so-sure look and feel
 System.setProperty("", "Windows");
 System.setProperty("os.version", "5.1");
catch (Exception ex) {