19

Thanks for your answers to my previous question about GUI in java. I now wonder what are the solutions chosen by professionals to get a nice GUI, for "real" applications. Do you use swing and JComponents and just change the "look and feel" ? Do you prefer awt or another library ?

Sorry if that question sounds weird, I'm a student and I don't really know how java is used in the real world...

Community
  • 1
  • 1
Jules Olléon
  • 6,733
  • 6
  • 37
  • 47
  • 2
    @Jules Olléon: I ship commercial software written in Java that works on Windows, OS X and Linux. I use Swing and IntelliJ's GUI editor (which is great in that it automagically hides a lot of boilerplate pointless lenghty uninteresting Swing code from you) and some custom-made components (these works 100% the same on every single platform). Like a custom dual/tri/quad progress bar, custom 'find-as-you-type' list (like the one Google is using for suggestions), and a few more advanced custom components specific to my problem domain. – SyntaxT3rr0r Apr 11 '10 at 16:35
  • @WizardOfOdds: What LaF are you using on Windows and Linux? Are you using the Windows and GTK style or Swing default? – Jonas Apr 11 '10 at 17:09
  • @Jonas: On Windows we offer to our users the choice between the default Swing layout and Nimbus. On Linux it's the default Swing, whatever that happens to be: but there are a *lot* of issues (including a lot of questions here on SO). For example we have "closable tabs" and we *must* run under 1.5. Hence we have our own renderer for tabs etc. It's a *wild* world of incompatibilities out there :) The software *works* on Linux and we devs do develop and test it on Linux, but we're only selling on OS X and Windows :) – SyntaxT3rr0r Apr 11 '10 at 18:52
  • @Jonas: to me Swing is mostly a bad joke: JTable are broken beyond repair, so are JTabbedPane (apparently Oracle may be taking desktop Java more seriously than Sun did). I mean, Swing is so broken and unnecessarily complicated that the Eclipse dudes decided to re-invent a wheel. And when targetting several platforms, you can quickly see Swing's shortcomings. It's not a funny API to work with. It's not OO, it's not fast (it's a pig), it's not pleasant to use. To me Swing is a POS. To get usable JTables, we had to do this: http://java.sun.com/products/jfc/tsc/articles/ChristmasTree/ Pathetic :) – SyntaxT3rr0r Apr 11 '10 at 18:57
  • @WizardOfOdds: Thanks, that was insightful comments. – Jonas Apr 11 '10 at 20:42
  • If you look at Scala, Swing is much simpler in that language, and I expect that development using Groovy would also be easier, and you can profile to see if you are taking a performance hit. – James Black Apr 12 '10 at 02:08
  • @SyntaxT3rr0r The link you provided just goes to oracle's Java homepage – Ungeheuer May 22 '17 at 16:26

7 Answers7

9

In our company we use Swing, as that is supported by the JVM out of the box, but we do use color coded background colors for some panels and buttons.

If we'd use something different, like SWT or Jambi we'd also have to roll out those frameworks for all platforms, and test those frameworks for all OSses and (supported) java versions. Not nice at all.

It is however fairly tricky to create a nice responsive application with Swing; so you really need to use SwingWorker and the like. With a bit of experience however you can create a nice application that way.

And even if it isn't the fastest framework to develop in, development time is really small compared to defining the functional requirements of the user interface, and testing and support when the version is released.

That said, our target is desktops. If you target mobile devices or also need a web frontend your choices may vary.

extraneon
  • 23,575
  • 2
  • 47
  • 51
4

I don't believe anyone prefers AWT anymore. Swing supplanted it entirely eleven years ago, building on top of it to correct flaws in the AWT 1.0 design.

Swing isn't the only way that professionals make Java UIs. That works for desktops, but there's also JavaFX now. For the web, UIs are built using HTML, CSS, JavaScript, and JSPs.

duffymo
  • 305,152
  • 44
  • 369
  • 561
  • 2
    For the love of God, please don't use AWT! Developing as a web-app has numerous advantages - not the least of which is easier deployment. – Stephen Apr 11 '10 at 14:34
  • @Stephen AWT GUIs and web-apps are totally different. It depends on what you're trying to do. Swing however has an advantage over AWT, although the AWT package is still used for event handling. – aduric Apr 11 '10 at 18:42
  • @aduric, I didn't intend to present them as the same. I was merely stating two things 1) awt GUIs suck, and 2) a web-app has numerous advantages. But, GUIs and web-apps aren't totally different, you can usually do most of what you'd want to do locally in a web-app. – Stephen Apr 11 '10 at 19:54
  • For the web GWT is also a great platform - especially if you already know Swing – Romain Hippeau Apr 12 '10 at 01:18
1

My experience is that most organizations that want to create rich GUIs still use Swing, and manually go through all the annoyances of layout managers, etc.

The use of SWT is fairly limited to organizations that are using the Eclipse RCP as their platform. I'm not sure why it hasn't caught on outside this platform.

It's sad to admit, but Java Swing GUIs don't generally look good unless you spend a lot of time creating a more native feel for them. Even then, they often lose out on aesthetics to equivalent programs written specifically for Windows and which use Window APIs like WinForms.

Uri
  • 88,451
  • 51
  • 221
  • 321
  • You should try the GUI designer in Netbeans! – Thorbjørn Ravn Andersen Apr 11 '10 at 18:53
  • Having the UIManager set the look and feel to the system class really is fine on Windows. Everything looks nearly the same as on a native Windows application. There are a few tiny differences here and there (mainly in the AWT components) but Swing does a nice job of emulating the native look. – bgroenks Feb 05 '12 at 17:47
1

The most decent Apps I saw in the last years were build using Eclipse Rich Client Platform

Eclipse uses the Standard Widget Toolkit

and provides Graphical Editing Framework (GEF)

stacker
  • 68,052
  • 28
  • 140
  • 210
1

We typically use Swing becuse it's supported in standard JREs out of the box. Normally we do the initial form design and event hookup in Netbeans and then export it to whatever we wish, Eclipse, for example.

Netbeans spits out pure Java using standard libraries (plus a jar or two you have to include) so it's no big deal designing the form in Netbeans and later moving on to something else.

Some people suggested doing form layout by hand using a layout manager. I see that as an option only if you are doing something big and very well budgeted that has to be maintained ad infinitum. Otherwise it's just too time consuming to be worth it.

Fabio de Miranda
  • 1,096
  • 1
  • 8
  • 13
1

We rely on SWT for our Java GUIs. Yes, you have to include an external native library, but the look and feel is native, more responsive (although Swing has become much faster in the past few years) and seamless with other apps on the target platform.

Zack Angelo
  • 425
  • 3
  • 8
0

Macintosh OS X creates their own Java runtime. They give Swing components the same look and feel as native applications.

I use strictly Swing. I distribute "real" desktop applications via Web Start for both Mac and Windows that interface with the user's smart card reader.

The NetBeans IDE gives you a WYSIWYG way to create your forms. I've tried it out, and it's pretty neat, but we still use Eclipse as our IDE and design the forms in code.

Marcus Adams
  • 53,009
  • 9
  • 91
  • 143
  • 1
    The NetBeans WYSIWYG editor is a nightmare. If you can afford it, I'd recommend JFormDesigner, or just do it by hand with a layout manager. It may be more work at first, but in the long run you have more control. – cdmckay Apr 11 '10 at 15:45
  • Sorry, it isn't. You've got full control of what goes where and all properties and bindings and whatnot. You just have to know where to look. Btw.: as far as I know, MacOSX makes *AWT* look like macos aqua, not swing. – Tedil Apr 11 '10 at 16:19
  • 1
    @Tedil, I did some research, and it seems like Mac OS X makes both AWT and Swing look like Aqua. We definitely use Swing, and it definitely looks like Aqua. – Marcus Adams Apr 12 '10 at 02:01