Re: Is it possible to know if windows is in XP style or classic style ?



Albert wrote on 07.12.2009 17:52:
Hi, i'd like to use to some feature not present in windows classic style. So i need to change some parts of my GUI depending on that.

Is there a way to know if windows is in XP style or classic style ?

This works for me:

String clsname = UIManager.getLookAndFeel().getClass().getName();
boolean isWindowsClassic = false;

if (clsname.indexOf("com.sun.java.swing.plaf.windows") > -1)
{
String osVersion = System.getProperty("os.version", "1.0");
Float version = Float.valueOf(osVersion);
if (version.floatValue() <= 5.0)
{
isWindowsClassic = true;
}
else
{
isWindowsClassic = (clsname.indexOf("WindowsClassicLookAndFeel") > -1);
if (!isWindowsClassic)
{
Toolkit toolkit = Toolkit.getDefaultToolkit();
Boolean themeActive = (Boolean) toolkit.getDesktopProperty("win.xpstyle.themeActive");
if (themeActive != null)
{
isWindowsClassic = !themeActive.booleanValue();
}
else
{
isWindowsClassic = true;
}
}
}
}

.