Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

53 views
Skip to first unread message

Albert

unread,
Dec 7, 2009, 11:52:05 AM12/7/09
to
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 ?

Thanks

Thomas Kellerer

unread,
Dec 7, 2009, 12:34:03 PM12/7/09
to

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;
}
}
}
}

Roedy Green

unread,
Dec 9, 2009, 5:14:29 AM12/9/09
to
On Mon, 07 Dec 2009 17:52:05 +0100, Albert <alb...@voila.fr> wrote,
quoted or indirectly quoted someone who said :

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

Do you mean the Java L&F or Windows itself.

If the L&F see http://mindprod.com/jgloss/laf.html

If you mean windows, you will have to figure out how to do it in C,
and write some JNI glue.
see http://mindprod.com/jgloss/jni.html
--
Roedy Green Canadian Mind Products
http://mindprod.com
The future has already happened, it just isn�t evenly distributed.
~ William Gibson (born: 1948-03-17 age: 61)

Albert

unread,
Dec 9, 2009, 6:50:10 AM12/9/09
to
Le 09/12/2009 11:14, Roedy Green a �crit :

> On Mon, 07 Dec 2009 17:52:05 +0100, Albert<alb...@voila.fr> wrote,
> quoted or indirectly quoted someone who said :
>
>> Is there a way to know if windows is in XP style or classic style ?
>
> Do you mean the Java L&F or Windows itself.
>
> If the L&F see http://mindprod.com/jgloss/laf.html
>
> If you mean windows, you will have to figure out how to do it in C,
> and write some JNI glue.
> see http://mindprod.com/jgloss/jni.html

Sorry, i didn't answer to Thomas Keller, but his trick works for me.

0 new messages