0
MiGレイアウトを使用して、このサンプルのようなレイアウトを実現したいと考えています。したがって、最後のJButtonはJFrameの下部にあります。Java Miglayoutギャッププッシュが希望通りに機能しない
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"), "");
}
}
私の問題は、私は追加したいJButtonが数が可変であるということですので、私はミグレイアウトに行定義を使用することはできませんので、私は、このコード(およびいくつかの派生)
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");
}
を試してみました
しかし残念ながら、これは望みどおりには機能しません。
提案がありますか?前もって感謝します。