Pete Freitag Pete Freitag

Better looking Java Apps

Updated on November 14, 2023
By Pete Freitag
java

One of the annoying things about GUI applications written in Java is that they do not conform at all the the Operating System's look and feel. As a result Java applications not only feel slow, but also look like an application that you should run on Windows 95. I fault Sun for not doing a better job with Java's default look and feel on Windows (The look and feel on Mac OSX is very nice, which is one reason I suppose many Java Developers prefer Mac's). I've heard that Java 1.5 will have an updated look and feel, I'm looking forward to that.

I noticed today that there is a class called SystemColor in the java.awt package (so it has been around since Java 1, yet no one uses it). The class has static fields that define things like the System window color, control color, select color, tool tip color, desktop color, shadows, etc. So for example if you have some Component all you need to do to make it show up with the proper color is the following:

component.setBackground( SystemColor.control );

I tested this on Windows XP, and it shows up in XP's tanish window color, which looks much better than the dark silver color that Java defaults to!


Better looking Java Apps was first published on November 13, 2003.

Weekly Security Advisories Email

Advisory Week is a new weekly email containing security advisories published by major software vendors (Adobe, Apple, Microsoft, etc).

Comments

GUI applications work great in Java. A perfect example is Eclipse. I would find it hard to imagine an Eclipse user "feeling" some difference between it and a native application. With Java Swing the same can be said when the developer uses the native LAF.

Of course, one should also take a look at Project Looking Glass from sun, which is one of the most beautiful windowing systems around and is quite snappy.
by Matt Liotta on 11/13/2003 at 5:42:14 PM UTC
Matt,
Eclipse doesn't use Swing, it uses SWT (the Standard Widget Toolkit) http://www.eclipse.org/articles/Article-SWT-Design-1/SWT-Design-1.html

SWT makes JNI calls to native OS widgets, which is why eclipse is so much faster, and feels more like a native OS Application.
by Pete Freitag on 11/13/2003 at 6:01:09 PM UTC
I‘‘m a big fan of SWT - if I do a Java application that requires a GUI, I always use SWT instead of Swing. I think the end user experience is much better, in that the person doesn‘‘t even know they‘‘re using a Java application.
by darron on 11/13/2003 at 6:08:48 PM UTC
I never stated that Eclipse uses Swing. I am perfectly aware of SWT, see my article on the subject.
http://www.devx.com/ibm/Article/6884

However, Java Swing can be implemented such that it uses the native OS widgets. This is how Java Swing works on Mac OS X for example.
by Matt Liotta on 11/13/2003 at 6:31:44 PM UTC
Sorry Matt, I misread your post... Basically what I'm getting at, is I'd like to see a JVM like the Apple/Sun JVM on OSX on Windows.
by Pete Freitag on 11/14/2003 at 1:11:21 PM UTC