Playing a bit to demonstrate how easy it is to fulfill a mock requirement using MigLayout, I was surprised by the result:
MigLayout layout = new MigLayout("wrap 3, debug"); JComponent content = new JPanel(layout); content.add(new JLabel("First:")); content.add(new JScrollPane(new JTextArea(10, 20)), "skip, spany"); content.add(new JLabel("Second")); content.add(new JTextField(10)); content.add(new JLabel("third")); content.add(new JTextField(10));
The layout idea is quite simple:
- three columns
- last column covering all rows
- first two columns - group of shortcut / component pairs
Unexpectedly, the last row of the first two columns occupies the entire available vertical space, which leads to the positioning of the last pair in its middle (the upper alignment is not an option, since they must be aligned along the baseline with each other)

uncommenting the last line above (adding a practically invisible dummy) shows the expected layout, but a hack that should not be part of the production code

Question: how to achieve the expected layout without hacking?
source share