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.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
I use to go for GridBagLayout for the control, but since java1.6 I'm going to use GroupLayout Is awsome.
Here an screenshot and sample code to use it!.
alt text http://img145.imageshack.us/img145/7844/screenshot1dz8.png
I was sick of all those layoutmanagers that needed alot of setup, werent very readable or exhausting to do manually, so I wrote my own very simple laoutmanager which uses the abstraction of two photocorners keeping each component in place. You can add your component like this:
parent.add(child,"topleft(0, 0.5)bottomright(0.5,1.0)");
Have a look here https://github.com/hageldave/UsefulStuff/blob/master/src/PhotoCornersLayout.java ;) you're responisble for a correct layout yourself though, cause it's not checking overlappings or other shortcommings of your layout.
GridBagLayout is powerful but quite primitively: the code that wires up the layout is very verbose. This utility library (actual just 1 jar file containing about 10 classes) simplifies a lot of works: http://code.google.com/p/painless-gridbag/ The following snippet is quoted from the home page of that site:
The only layout manager that I have found, that I actually like is the Relative Layout Manager. The Relative Layout Manager works in a way that is consistent with how dialog boxes are conceptually organized. One draw-back is that while this layout manager deals with additive constraints. It does not seem to deal with ratio constraints. Fortunately it is pretty well designed, and I was able to implement this feature.
Spring layout which was developed for the mantissa gui builder which is part of netbeans.
I use GridBagLayout for form like layouts, use BorderLayout for simple layouts, and FlowLayout for number of horizontal icons/buttons that have some spaces in between. Netbeans is also a good GUI builder that can avoid a lot of tedious layout codings to save your time.