views:

75

answers:

3

They have this very cool drag and drop thing that creates GUI on the fly. But I don't get to learn anything out from this method and I feel guilty about it. Do most of the Java programmers use this method? Because realizing the code it generates, it's quite impractical coding the GUI by hand IMO.

A: 

I'd hazard a guess that "most" devs who are creating Swing GUIs using Netbeans will use this method. It's important to be able to write the same code yourself, albeit impractical.

That said, who the heck writes Java programs that use a Swing GUI?

Matt Ball
What's better alternative to using Swing? SWT/JFace?
pneftali
+2  A: 

There's nothing wrong with using a GUI builder, as long as you understand what the tool is doing and the implications of using the tool of choice.

The first thing you need to know is what the tool is doing. In this case, you should understand Java Swing and topics such as layout managers, components, concurrency issues that arise when using Swing (this will be handy even when using a tool), event listeners and handlers. Really, you should be able to walk through a simple tutorial, such as this one on Creating a GUI with JFC/Swing. You don't need to be an expert, but you do need to be at least comfortable with reading the generated code and understanding what it does.

The second thing you need to be aware of is the implications of using whatever GUI building tool that you are using. A big implication is that if someone goes to edit the GUI code, they will have to either use your tool or edit the code by hand. If you work in an environment where people are using multiple IDEs and code editors, then someone who uses a different tool then you won't be able to work with your generated code without breaking your ability to use the tool. Most generators lay out their code in a specific manner so that it can be read and processed by the tool - different GUI builders generate different code and won't be able to easily work with each other's code. Also, because of this, editing the code by hand might break the ability of a GUI builder to work with the generated code.

If you understand the tool, what it does, and are willing to accept the risks, go for it. I'm a firm believer in using whatever tools are appropriate to get the job done and that includes GUI builders.

Thomas Owens
That's a relief, thank you :)
pneftali
+1  A: 

Coding Swing by hand isn't bad at all once you get a grip on layout managers, so it all depends on whether you want to learn Swing. Knowing Swing is far from necessary but it is a pretty well designed bit of code.

CurtainDog
Thanks. But do you think it is still worth learning Swing right now to be able to code it by hand or should I just rely on tools like Netbeans offer? I have read this post from this guy :http://stackoverflow.com/questions/3270771/future-of-gui-development-in-java-closed , but I am still not 100% convinced it's true, but somehow it is a thought to consider. What do you think?
pneftali