Я хочу получить макет, как в этом примере, используя макет МиГ. Таким образом, последний JButton расположен в нижней части JFrame.Java Miglayout gap push не работает по желанию
public class MainFrame extends JFrame {
public static void main(String[] args) {
MainFrame mainFrame = new MainFrame();
mainFrame.setDefaultCloseOperation(EXIT_ON_CLOSE);
mainFrame.setPreferredSize(new Dimension(400, 300));
mainFrame.pack();
mainFrame.setLocationRelativeTo(null);
mainFrame.setVisible(true);
}
public MainFrame() {
this.setLayout(new MigLayout("debug", "[grow, fill]", "[][][]push[]"));
this.add(new JButton("Test1"), "wrap");
this.add(new JButton("Test2"), "wrap");
this.add(new JButton("Test..."), "wrap");
this.add(new JButton("TestBottom"), "");
}
}
Моя проблема в том, что количество JButtons я хочу добавить переменную, поэтому я не могу использовать определение строки в МИГ макете, так что я попробовал этот код (и несколько выкладок)
public MainFrame() {
this.setLayout(new MigLayout("debug", "[grow, fill]", ""));
this.add(new JButton("Test1"), "wrap");
this.add(new JButton("Test2"), "wrap");
this.add(new JButton("Test..."), "wrap");
this.add(new JButton("TestBottom"), "gaptop push");
}
Но, к сожалению, это не работает по желанию.
Любые предложения? Заранее спасибо.