简体   繁体   中英

Creating GUI's using Java Swing with Netbeans IDE

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM