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?
2
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.
I did a lot of Swing programming in the late 90’s, but I don’t do very much nowadays, so I don’t know if it’s still an issue or not. It used to be the case that if you used a native look and feel, you’d occasionally run into layout issues when you ran it on another platform, due to slightly different control proportions and such. Using the default metal look and feel avoided those kinds of issues.
Of course there’s always the more puerile possibility that Java likes their look and feel better and it’s their language, so there 😛
1
I’m pretty sure that swing was designed to be lightweight with Java’s (Sun’s, now Oracle’s) own widgets designed for cross platform usability. The graphics for the widgets look the same and are distributed along with the platform package. The native feels require interfacing with the OSes look and feel, which make it more heavyweight. Other GUI toolkits do this natively, like AWT.
3