views:

263

answers:

4

I am planning to write a Swing-based application (using Netbeans 6.8).

It seems that Netbeans has a very advanced GUI Editor... Still I have my doubts regarding the code generated by it. Additionally I don't like the fact the part of the code is locked (still I understand the need).

Has anybody used Netbeans GUI Editor with success ? Does it "scale" ?

+6  A: 

Yes, the NetBeans GUI builder is one of the finest around. I was particularly impressed with how well it handles the infamous GridBagLayout.

Borland JBuilder was in my experience the very best round-trip GUI editor; if I remember correctly, it produced code without "locked areas" and would usually continue to work gracefully with GUI code that you had manually tweaked.

Still, I have yet to find a Java Swing GUI editor that doesn't occasionally choke on a complex layout, i.e. enter a state where further editing is no longer feasible and/or requires some backing up or fixing.

Thus, I prefer to hand-code all my GUIs. Heinz Kabutz of JavaSpecialists tells me his GUI editor is vim. However, I admit that most of my other friends and colleagues consider me crazy for doing this.

Carl Smotricz
Thanks for your answer. Much appreciated.
Andrei Ciobanu
I actually like hand-coding GUI's in Swing, but maybe I'm just crazy? I've done this for moderately complex programs, and it worked out fairly well.
Tikhon Jelvis
I always hand-code my GUIs. But I try to avoid LayoutManagers that require a lot of boilerplate code (eg GridBagLayout). I much prefer "smart" layouts such as DesignGridLayout or libraries that wrap GBL to give it a better API (painless-gridbag).These make it easy to hand code GUIs and still make it possible to maintain them afterward.
jfpoilpret
Interesting what you said about JBuilder's round-trip. When I used it I found that it always failed to adapt to my manual code tweaks and this is one of the things that turned me off of gui builders. However, this was long ago and it sounds like it might be better now.
Marshall Alsup
@Marshall Alsup: My guess is that we just had different coding/tweaking styles, and I coincidentally tended toward JBuilder friendly changes and you did not.
Carl Smotricz
+2  A: 

I have always prefered to write my Swing UIs by hand. I've tried Netbeans but I just didn't trust it to do the right thing for a complex UI (although it was quite awesome for a small simple UI).

I think a lot of us fear writing Swing Layouts by hand because of GridBagLayout. Its not that hard once you've used it a few times. I used to swear by it. However, recently I've moved to a new job and their existing code uses TableLayout instead. Its much simpler and seems just as powerful to me. I've grown to prefer it to GBL. I think you should consider it if you're new to writing Swing.

I'm sorry but I'm not sure about your question of scale.

Best of luck!

Funny side story about JBuilder. My friend who taught me swing taught me to code it by hand, and he always had me put the layout code in a jbinit() method. For several weeks I assumed this was just some code style he used. It was only later I learned that it was an auto-generated method of JBuilder at the time. I didn't need to be using it at all. I was such a n00b :)

Marshall Alsup
Interesting, I'd never heard about TableLayout before. Another "newfangled" layout manager I can recommend is GroupLayout, it's even more versatile than GridBagLayout yet (IMO) simpler to work with. Where I used to nest components to create complex layouts, I can now nest GroupLayouts in a single component. Finally, MiGLayout is 3rd party but also has a great ratio of ease-of-use to power; preferred by many and a candidate for the Sun JDK.
Carl Smotricz
+4  A: 

With the newest versions of Netbeans, you can share projects between Eclipse and Netbeans. So, if you don't like coding in it much, you can use it just for the GUI features and then edit the code in Eclipse. Make sure you create your project in Eclipse first, and then use the importer. They will share the same directory.

http://netbeans.org/kb/docs/java/import-eclipse.html

Chris Dennett
Cool, I think this is useful info, +1!
Carl Smotricz
Wow, that is cool! Thanks for the info.
Marshall Alsup
+2  A: 

I recently (4 weeks ago) switched from eclipse/SWT to Netbeans 6.8/Swing (after being fed up with some plugin licensing issues in Eclipse). I came in cold not being familiar with either Netbeans or Swing and was quickly impressed. I managed to convert 4 years of SWT experience into Swing experience very quickly and now consider Netbeans the best Java GUI editor. Whilst some parts of autogenerated code are read only - this is a good thing. Eclipse allows you to edit the autogenerated code and this can cause major headaches with layouts, alignment and so on if you make a mistake. Netbeans allows you can create custom 'event handling methods' (my terminology only) which gets the autogenerated block to invoke your methodd at particular points in the lifecycle so you can access the 'read only' code whenever you need to.

So stick with NetBeans, its the best Java Swing environment there is.

You do NOT want to code by hand, for any reasonably sized app. Let the GUI do most of the plumbing for you (especially when using the the different layouts - this alone will make you tear your hair out), so you can focus on the service/business logic.

Serge Merzliakov