Я пытаюсь понять MigLayout, поэтому я хочу создать таблицу с разными панелями внутри.Как складывать компоненты внутри вертикальной ячейки в MigLayout?
На данный момент это выглядит так:
Ячейка 2 содержит 3 метки, которые должны стека. Поэтому я попытался дать ячейки 2 это собственный макет с center2.setLayout(new MigLayout("flowy"));
, но затем другие компоненты получают суматоху:
Так есть ли способ, чтобы сложить 3 метки в ячейке 2 по вертикали?
[EDIT]: центр1 и центр2 должны иметь такую же высоту!
Мой пример класса PageThree.java:
public class PageThree extends JPanel{
public PageThree() {
setLayout(new MigLayout());
JPanel contentPanel = new JPanel();
contentPanel.setLayout(new MigLayout("width 100%"));
JPanel topHeading = new JPanel();
JPanel westAreas = new JPanel();
JPanel center1 = new JPanel();
JPanel center2 = new JPanel();
// If I give center2 its own layout with flowy,
// the 3 labels are stacked vertically,
// but the other components get cluttered
// center2.setLayout(new MigLayout("flowy"));
JPanel center3 = new JPanel();
center1.add(new JLabel("center1"));
center2.add(new JLabel("center21"));
center2.add(new JLabel("center22"));
center2.add(new JLabel("center23"));
center3.add(new JLabel("center3"));
topHeading.add(new JLabel("topHeading1"));
topHeading.add(new JLabel("topHeading2"));
topHeading.add(new JLabel("topHeading3"));
westAreas.add(new JLabel("westAreas"));
contentPanel.add(center1, "width 40%");
contentPanel.add(center2, "width 60%, wrap");
contentPanel.add(center3, "width 50%");
contentPanel.add(topHeading, "width 100%, dock north, split 3");
contentPanel.add(westAreas, "dock west");
}
}