views:

368

answers:

5

I've been writing Java web (JSF, Struts, JSR168) apps for a number of years. With the recent departure of a colleague, it looks like I'm going to be building more client applications. I've used Eclipse since the beginning and I'm really comfortable with it. It feels as though SWT is waning (just an opinion based on literature I can find) and Swing is surging.

My question: Is there value in learning Swing through writing apps by hand in Eclipse (as opposed to using Matisse in Netbeans)?

+3  A: 

Yes, definitely - even if you plan on using Matisse most of the time, you will benefit from having at least a reasonable understanding of the Swing code under the hood.

William
A: 

It sure will help. Maybe you'll reach the end of what Matisse can do, and want to tweak some of the code by hand. At this point it will be better to know what happens under the hood.

boutta
+7  A: 

Yes, it is very valuable to learn coding Swing apps by hand. One reason for this is that no GUI-Designer I know always does the things you want them to do. The other - and in my opinion more important reason - is that most GUI builders (especially NetBeans') generate all and everything into one single class. This can be very annoying because the maintainability is reduced a lot (separation of concerns). Also many GUI builders have blocked regions, i.e. you cannot modify the generated code by hand. Or if you do the GUI builder will overwrite it the next time you use it.

However that standard LayoutManagers coming with Swing are very complicated. This is why I suggest that you give MigLayout or JGoodies FormLayout a try. On the JGoodies site you also find other libs for alternative Look&Feels, Binding and Validation, which can be very useful.

I would also suggest that you have a look at the Presentation Model pattern (Martin Fowler), which helps a lot if you want to unit-test your GUI-behaviour.

If you then are motivated to improve the design and add some very cool effects to your application check out the book Filthy Rich Clients.

Hope it helps.

Roland Schneider
NetBeans' Matisse generates all into one single class only if you do it that way. I think it's better to make separate panels, and then build the whole view from them. And the blocked regions - try to right click and select "customize code". You can write whatever into the blocked regions. Matisse is quite flexible, you just have to use it in the right way :-)
Joonas Pulakka
I know, but it is rather complicated imo. Does it support syntax highlighting / auto-completion?
Roland Schneider
A: 

Note that using Matisse and writing Swing by hand are not mutually exclusive at all. Matisse just produces Swing code, and you can customize it. You can make part of your GUI with Matisse, and the part next to it by hand, for instance. Get the best of both worlds - that's how I do it, at least.

Fast way to learn how to do something in Swing is to do it in Matisse, and then see the code it produced.

Joonas Pulakka
A: 

You definitively need to know how Swing works since you will most likely have to adapt and change things which the GUI prgram expects you to know how works and what it is called.

The Java Tutorial has a good Swing trail: http://java.sun.com/docs/books/tutorial/uiswing/

Thorbjørn Ravn Andersen