Java Swing, the Shining Example of Usability?

Sun's Java UI toolkit, Swing, was a great idea, though of course it's taken a long time to come even close to its original ideals: a powerful, attractive, full-fledged windowing toolkit independent of the underlying OS.

In order to have the cheek... the gall... the nerve... to say "don't use your native windowing system, use ours instead," the alternative windowing system needs to be something pretty darned special. It needs to excel in compelling ways that make the decision to use it a virtual "no-brainer". It simply being the default or the standard toolkit built-in to a programming language isn't the right reason to use it.

The main compelling choice behind Swing has always been its platform independence. Write a Swing app on Windows, and see the same version run on the Mac without recompilation. This is great for "zero-install, rich client" apps (e.g. distributed over Java WebStart), because you don't always know what OS the client will be using.

But multi-platform capability isn't the "killer application" of any windowing toolkit; and it certainly isn't unique to Swing. Flash, which is also multi-platform, springs immediately to mind as a modern Java-killer (at least in the browser).

So, what is it that Sun needs to do in order to make Swing the compelling toolkit of choice?

Java is becoming increasingly accepted on OS X, so it would be great if Sun were to take a leaf out of Apple's tree (so to speak): Apple has worked hard to make its platform be seen as the centre of the user interface universe (I would say "userverse" if I didn't think that it would cause half the readers to stop reading straightaway); almost to the extent that Apple is synonymous with usability, that is, an easy-to-use platform populated with easy-to-use programs.

Sun made a half-hearted attempt at defining a style guide for Swing a few years ago, and even released it as a couple of very thin books which found their way into my local Borders. I read both volumes, they were terrible. I couldn't help but feel that the style guide was just kowtowing to what some people in Sun felt that they ought to be doing.

I could see their thought process going something like this: "There really ought to be some UI guidelines, kind of like what Apple and Microsoft do, so I suppose we should do something like that as well." There was no thrust, no "let's make developers adhere to our UI guidelines; let's make every Swing application ultra-consistent; let's make users love us for our benevolent attention to their productivity needs."

A big part of the problem (reading between the lines and examining the evidence) seems to be the inherent culture at Sun. Sun is many things, but it isn't big on user interfaces. For example, the "Juicy News Network" (JNN) RSS reader written by Sun's CTO of Tools James Gosling ("Mr Java") is a shining example of how to make a simple UI clunky and difficult to use. Its UI has some surprising glitches (e.g. click on a newsfeed on the left and the panels on the right don't catch up). It took a while to work out how to add new newsfeeds (you have to drag a URL onto the left panel). There's no "affordance" in the UI to make this basic usage obvious; no visual hint or mouse feedback to suggest that the UI is capable of drag-and-drop. Truth be told, the rest of the UI is so ugly that I naturally assumed that drag-and-drop wouldn't feature.

JNN was written in a weekend by Gosling so I shouldn't be too critical of it. But it's still a good example of how Sun tends to release a UI which is "just good enough", thinking that that's good enough. And that's where the culture thing comes into it. "Just good enough" means a UI which lets you get the job done, but is clunky, has glitches, is difficult to use. In a company like Apple, "good enough" means something completely different: it means a UI which is consistent with their universe of other UIs, a UI which is nice to look at (aesthetically pleasing) yet instantly, obviously usable.

It's encouraging to see that Sun has enlisted the help of vocal UI experts like Karsten Lentsch, for future versions of Swing. Lentsch's products actively encourage the programmer to create usable UIs. If the UI breaks some basic usability rules, the product corrects it (actively, at run-time); e.g. too many nested borders.

Sun needs a lot more of this sort of thing. But they need to go further, and quickly. The exodus away from Swing has already begun (Flash, SWT). However good Swing becomes, the belief is deeply rooted that Swing UIs suck and that Swing itself is clumsy and slow (the former is often true but the latter isn't).

To entice developers back to Swing, Sun needs to do something special: reinvent Swing as the pinnacle of usability. Relaunch javadesktop.org to concentrate less on the slightly desperate Swing Sightings, and instead to focus primarily on usability (and how to achieve it using Swing), including tutorials on usability, and sporting screenshots of zappy-looking Swing UIs, perfect examples of usability and aesthetics combined. Translucent panels, anti-aliased fonts etc. If Swing can't currently do any of this particularly well (or at all), make it possible.

This would quickly set a direction for Swing, and give it some much-needed momentum. It would also provide a reason, in addition to multi-platform ability, to justify the overhead of an extra windowing toolkit on top of your OS's native toolkit. The justification is simple, and should be indisputable: "Use ours because it's better."

About the Author

Matt Stephens is a senior architect, programmer and project leader based in Central London. He co-wrote Agile Development with ICONIX Process, Extreme Programming Refactored, and Use Case Driven Object Modeling with UML - Theory and Practice.