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 fin开发者_如何学Pythond 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.
精彩评论