简体   繁体   中英

Netbeans GUI Builder with Java Swing; What's the easiest way to organize Widgets?

I'm developing a GUI application rapidly using a GUI buidler (Netbeans). I am frustrated with the Swing widgets... when I resize one the rest seem to "reorganize" themselves in the wrong places.

What do you guys use to tame such chaos? I was thinking of tables.... but couldn't find any in the Netbeans Palette.

Regards

Use MigLayout .

If you want to use pure Swing, use GridBagLayout and be prepared for a lot of pain.

Coding GUI manually should be the preferred way (at least for the sake of maintainability). There are a few, open source, Swing layout managers that are pretty good at it.

Someone has mentioned MigLayout, which allows any layout, is quite simple to use, but often requires some tweaking until you get what you want.

On the other hand, you also can use DesignGridLayout , which is suitable for most common layouts and is easier to use (thanks to its fluent API) than MigLayout.

You are never forced to use a single layout manager. That is the problem with using an IDE to design a GUI. You get bloated code because the tool uses a single layout manager with multiple confusing constraints in order to get the form layout out the way you drag and drop it.

Create your forms manually and use nested panels with different layout managers to layout the components as desired. The code is easier to maintain and understand.

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