set different look and feels in Swing Application Framework jsr 296
My application uses SAF (jsr 296). I want to use different look and feels on different platforms:
A default (Java) for Linux
And system (native) for Windows.
ADDED:
So far I hardcoded L&F for the Windows OS in the startup() method of my Application class (as suggested by Joy and Thompson):
if (SystemUtils.IS_OS_WINDOWS) {
UIManager.setLookAndFeel(
UIManager.getSystemLookAndFeelClassName());
}
In the application.properties file, the def开发者_JAVA百科ault L&F is specified.
Is there no better way?
A default (Java) for Linux. ..system (native) for Windows.
if (System.getProperty("os.name").startsWith("Windows")) {
try {
UIManager.setLookAndFeel(
UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
}
Will set the look & feel for Windows to the native PLAF, while keeping the (default) Metal PLAF for Linux/Unix & using the default for Mac, which we are reliably informed is named:
com.apple.laf.AquaLookAndFeel
I would probably recommend Nimbus for the Linux/Unix machines. The Metal PLAF is so ..last millennium.
Try this:
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
It will set look and feel based on system on which your application is running.
you don't need so much code to do so. You can create a platform specific property file, or use "system" LnF in the application properties. More details at http://kenai.com/projects/bsaf
精彩评论