Which Layout Manager do you use?

2019-03-18 02:12发布

What java GUI layout manager does everyone use? Lately, I have been using MigLayout, which has some powerful component controls. Just wanted to see what other developers are using other than the standard JDK ones.

22条回答
Rolldiameter
2楼-- · 2019-03-18 02:46

I'm a big fan of using TableLayout instead of GridBagLayout. Everything just makes sense, whereas every time I try to use GridBagLayout it crushes my soul.

查看更多
甜甜的少女心
3楼-- · 2019-03-18 02:46

I've found that for any non-trivial GUI I use multiple layouts with nested sub-panels where the main panel may have a GridBagLayout and each sub-panel (typically without a border or indication that it is a panel) uses a simpler layout where possible. Typically I'll use BorderLayout, FlowLayout, and BoxLayout for smaller, simpler sub-panels. By dividing small sections of the GUI into sub-panels and using the simplest layout possible to control that section of the GUI you can create complex, well arranged displays without too much headache from GridBagLayout's many options. Also, by grouping like display functionality into a panel, it creates more readable code.

查看更多
We Are One
4楼-- · 2019-03-18 02:48

I use the GridBagLayout. It seems to take alot of code, but it makes very good looking layouts.

I also like to combine BorderLayout with GridBagLayout panels for great customizability.

查看更多
爷的心禁止访问
5楼-- · 2019-03-18 02:48

I've used GroupLayout as well. Again, its a standard JDK layout manager as of Java6, but you can find the library separate as well.

查看更多
甜甜的少女心
6楼-- · 2019-03-18 02:49

I have started using Swing recently and I am using GridBagLayout.

查看更多
欢心
7楼-- · 2019-03-18 02:51

I prefer to minimize dependencies on 3rd party libs, so it's usually BoxLayout for dialogs and GridBagLayout for "complicated" layouts. GridBagLayout is easy enough to understand, but a bit hard to configure. I wrote myself a tool for creating the code from HTML layouts (hope that helps others too): http://www.onyxbits.de/content/blog/patrick/java-gui-building-gridbaglayout-manager-made-easy

查看更多
登录 后发表回答