Java – Why Doesn’t Swing Look Native Out of the Box?

javaswing

Java Swing GUI's don't look native by default (Except on Mac OS X for some reason). Swing uses it's own look and feel. You can get Swing to use the system look and feel by putting:

javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());

in the beginning of your main method, but: Why isn't this done by default?

Best Answer

Java language "philosophy" is WORA:

Java is ...intended to let application developers "write once, run anywhere" (WORA), meaning that code that runs on one platform does not need to be recompiled to run on another.

Explanation for default given in Swing tutorial (Available Look and Feels) looks consistent with above:

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...

Apparently, library designers decided that "CrossPlatform... looks the same on all platforms" deserves to be default for the library in the language primarily intended to be cross platform.

Marketing / designer dreams could play their role here, too. Every library designer hopes / expects it to be popular and widely used (otherwise, there's little sense to invest effort into it). If Swing designers expected it to be used very widely, consistent (not system dependent) L&F could be considered an advantage, so that users running the same (popular! how could it be different?) Swing application on different platforms would feel comfortable with familiar interface.