0

My environment is JDK6. And I test my code in Win7 and Win2003 both using the same JRE.

I installed JAVA WindowsLookAndFeel using code "UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");".

I supposed UI should behave consistently in Win7 and Win2003 after I installed WindowsLookAndFeel. I think it should be different from using code "UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());"which is OS-related. But the truth is UI looks like Win7 in Win7, looks like Win2003 in Win2003. I read source code of WindowsLookAndFeel and found if windows NT version is less than 4.0, WindowsLookAndFeel will use WindowsClassicLookAndFeel instead. But Win2003's windows NT version is 5.2.

And even CrossPlatformLookAndFeelClassName also has a different java look in Win7 and Win2003.

Can you explain it? I am really confused.

Can I have same UI on different windows OS by installing WindowsLookAndFeel? Thank you.

1 Answers1

2

I supposed UI should behave consistently in Win7 and Win2003 after I installed WindowsLookAndFeel.

That supposition is not correct. The Oracle tutorial says this:

"For Windows, the System L&F is "Windows," which mimics the L&F of the particular Windows OS that is running—classic Windows, XP, or Vista."

... and that is what WindowsLookAndFeel implements.

And even CrossPlatformLookAndFeelClassName also has a different java look in Win7 and Win2003.

The tutorial says this:

"CrossPlatformLookAndFeel—this is the "Java L&F" (also called "Metal") that looks the same on all platforms. It is part of the Java API (javax.swing.plaf.metal) and is the default that will be used if you do nothing in your code to set a different L&F."

I think that might better be stated as "... aims to look the same on all platforms". In reality, it is really difficult to get UIs to look identical across platforms.

Another possibility is that you are (somehow) picking up a different default look and feel in different versions of Java and/or platforms; e.g. Metal versus Ocean versus Nimbus.

Finally, you may simply be expecting too much. Win2003 is not listed as a supported platform for Java 7. It was supported for Java 6, but clearly it wouldn't have been a high priority for Sun / Oracle to get the UI consistency perfect for a legacy Windows platform that was due to be de-supported.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • Hi Stephen, Thank you so much. Another question, is WindowsClassicLookandFeel also OS-related too? – user2328167 Apr 28 '13 at 04:15
  • The tutorial implies that it is not. But I'd not be surprised if the "classic" look and feel still varies across different Windows versions and/or Java versions. The only real way to be sure is to try it and see ... for your specific application. – Stephen C Apr 28 '13 at 04:24
  • Stephen, I tried WindowsClassicLookandFeel and got the conclusion based on the same jre version: java look is diffrenrent in win7 and 2k3. And I read code and found WindowsClassicLookandFeel extends WindowsLookandFeel which means it's still OS-related like WindowsLookandFeel. Thank you so much Stephen. You correct my understanding. I thought systemlookandfeel is WindowsLookandFeel in win7/visata, is WindowsClassicLookandFeel in win2k, xp... I was wrong! – user2328167 Apr 28 '13 at 04:32