There are 8 layout managers in the Java library alone, and then there's a bunch of 3rd party products as well.
The other day, I tried to use SpringLayout and... well, it ain't working out for me. See my other question. So... if you have a Swing app to design, and you want your layout just so, what are your preferred layout managers? Any interesting/useful experiences to relate?
Update: Yup, sure I'm aware that different LMs are appropriate for different layouts. But I'd expect that most of you use 1, 2 or maybe 3 for most everything you do, or you swear by a single one that's so versatile you never need anything else. With enough responses, I'd expect to see something like a bell curve, with a peak on GridBagLayout or MigLayout (for example) and a long tail of a few stragglers using (say) BoxLayout or FlowLayout.
Hopefully, the distribution of responses will reveal some trends as to what people use most to Get Stuff Done™
OK, after almost 2 days, MiGLayout is definitely out in front! Its fans will be happy to hear that it looks like this layout will be entering the "official" library soon.
GroupLayout, FormsLayout and TableLayout are relatively new and haven't gotten much exposure. Perhaps others will be as surprised to find out about them as I was.
The borderlayout arranges the components to fit in the five regions: east, west, north, south, and center. The CardLayout object treats each component in the container as a card. Only one card is visible at a time. The FlowLayout is the default layout.
Answer 1: d. BorderLayout and GridLayout easily deal with this situation.
BorderLayout is the default layout for the window objects such as JFrame, JWindow, JDialog, JInternalFrame etc. BorderLayout arranges the components in the five regions.
MiGLayout, no doubt. Honestly, it's the only Swing layout manager I know of that makes any sense.
The mere fact that there are 8 layout managers in the core JDK is a good sign that the Swing creators had absolutely no idea about what they were trying to do. This is not to trash the rest of the Swing - it's a good GUI toolkit, except for the layout managers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With