12

I have used Java Swing for some desktop applications. But I haven't used other GUI frameworks that much so I can't compare them.

There is definitely some things that I like with Swing and some that I don't like, but that is the situation with almost everything.

What are the biggest drawbacks with the Java Swing GUI framework?

Jonas
  • 14,887
  • 10
  • 70
  • 103

3 Answers3

3
  1. You have to have java installed somewhere. This is true of all GUI frameworks of course, but java has the perception of a 2 ton gorilla. It's gotten loads better, but those early java applet days turned a lot of people off. If you only need it to run your one app, it's a lot of maintenance to keep it up to date with security patches and the like. Everybody's gotta have Flash for youtube, .Net framework installs behind the scenes and everybody has javascript enabled on their browser. Java is usually an extra thing to do.

  2. All though it's sorta write-once, run anywhere, you still find that Mac OSX doesn't have this newfangled thing you want to use or one client refuses to upgrade their mandrake linux past JRE 1.4.

  3. As a dev, you have to think about threading. And it's in a tricky way, as multi-threading is possible but swing pretends like it's all single-threaded. But then half the libraries you pull in have some degree of multi-threading and assume that you know about EDT invokeLater and it forces a lot of lessons the hard way.

  4. Swing experience doesn't transfer easily to other kinds of UI development. For instance if you are a whiz at tables in .css, you're going to be completely waylaid by Jtables, renderers, editors, etc.

In general, the main problem with Swing is that it didn't live up to how it was marketed. It's a perfectly adequate technology for a lot of use cases, but those first 5 or 6 years were full of awful implementations and atrocious applets. And now it's old tech - on to Web 3.0 or whatever.

All that said, I do like Swing and think the pros generally outweigh the cons when you need what it offers. However the web experience is so ubiquitous now that many users are going to have an easier time with a web app than the most streamlined amazing swing app. And there are awesome Swing apps out there, but they don't seem to be mainstream.

2

Jonas,

Swing generalises your underlying architecture to provide you with a platform neutral user experience. The only heavyweight component (provided by the OS) is the JFrame container and the rest is pretty much handled by the Swing tookit. AWT on the other hard, asks the OS to draw all of it's UI components which means it's faster in a lot of ways as your using the native UI components specific to the OS. SWT tries to achieve a middle ground, for various standard components like buttons and labels (which are available on most OS), it lets the OS deal with those and for other specialised components, SWT will handle the creation for you.

That been said, I can outline the drawbacks.

(1) Since the toolkit creates and renders the components for you rather than asking the OS, you don't get to take advantage of the speed of the built in components provided by the OS.

(2) The UI isn't particuarly attrictive as it looks alien to most OS platforms regards of what look and feel you use.

(3) Some of the layout managers i.e GridBadLayout etc could be better simplified. I've lost count of the number of projects I've worked on where people have wrapped the GridBagLayout in some bespoke code to get a simpler way to use it.

I'd advise you to write a simple app in AWT, Swing and SWT and compare the development approaches an the final product between them all, then review the various comments made from other developers and decide which one works best. I've worked with Swing for many years and I used dislike SWT, but I'd come to realise that Swing is a lot more complicated than it needs to be when compared to other frameworks out there.

-2

Swing is slow (bad performance), hard/clumsy to use (compared to many other ones) and it doesn't look very good, in fact very bad, on some platforms.

Anto
  • 11,197