Java Swing returns

Sun presented all day yesterday at work. I attended the session on desktop Java. So far as I can tell, the key changes are better windows integration (don’t care), an effort to get vendors to preload the JRE on both windows and linux, and a wizzy new demo app that makes heavy use of J2D to look a bit like a Mac OS X widget with lots of translucency, fades, throbs, and visual effects lifted right off of OS X.

I will say that the demo app was pretty, but having written swing and J2D in the past, I know how much work went into that app and I shudder at the level of effort it would take the average developer to replicate it. Most of the UI elements are not in the standard Swing package and are custom widgets making use of Java 2D graphics. Those that are swing widgets have been subclassed and had their rendering code replaced with some fancy hollywood quality graphics.

The NetBeans GUI builder (Matisse I think) was also shown. It looks so-so and it uses code generation which naturally makes it nearly useless.

The Q&A was also rather brutal with one attendee asking “why does it take 10 pages of code to replicate what I can do in six lines of HTML?” Their answer – they are working on a new app framework to hide the complexity of the Swing framework. Hello? Why isn’t the first framework simpler? Abstracting a framework behind a framework is excessive. No wonder the thing crawls at times.

My question/comment was to suggest that they bail on code generation and focus on the real pain point. Intelligent default sizes for widgets. For example, I constructed a standard outlook-style browser with a vertical split pane that has a scrolling list on the left and content area on the right. If there are no items in the list, it initially displays at something like 4 pixels wide. If I populate it with items first, it displays at a reasonable initial size.

So, under what circumstances does Sun imagine I might want a 4-pixel wide list? If I did want one that narrow, what are the odds that I’d want it to expand to 100 pixels when I added data? I’d say that Swing remains a nightmare framework of poorly chosen defaults, code generation gui builders, and ugly rendering. It can be improved with Java 2D rendering, but at that point, you might as well write all your own widgets as its not that hard to do raw mouse/keyboard event tracking.
Once again, Sun spends vast amounts of time, energy, and cash gazing at their navels instead of simply adopting proven solutions.

Leave a Reply

You must be logged in to post a comment.