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 os.name 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 -Dos.name=windows MySwingApp
java -Dos.name=mac MySwingApp
Properties p = System.getProperties();
p.put("os.name", "Mac");
System.setProperties(p);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
UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
// not-so-sure look and feel
System.setProperty("os.name", "Windows");
System.setProperty("os.version", "5.1");
UIManager.setLookAndFeel(
"com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
}
catch (Exception ex) {
ex.printStackTrace();
}
mail_outline
Send comment, question or suggestion to howto@rgagnon.com
Send comment, question or suggestion to howto@rgagnon.com