MigLayout 面板内的 MigLayout 面板 - 将其与底部对齐

MigLayout Panel inside a MigLayout panel - aligning it to the bottom

带有所有按钮的右侧面板,我想对齐到底部。

JPanel easternDock = new JPanel(new MigLayout("", ""));
easternDock.add(button1, "wrap");
....
this.add(easternDock);

我想我可以在所有按钮上方添加一个组件并使其在 y 维度上增长以填满屏幕,但我不确定要为此使用哪个组件而且我不能找到设计用于执行此类操作的任何组件。

我这样做的方法是在 "easternDock" 面板中添加另一个面板,其中包含所有组件,然后 "easternDock" 使用 push Column/Row 将另一个面板推到底部]约束。

来自米格作弊 sheet : http://www.miglayout.com/cheatsheet.html

":push" (or "push" if used with the default gap size) can be added to the gap size to make that gap greedy and try to take as much space as possible without making the layout bigger than the container.

这是一个例子:

public class AlignToBottom {

public static void main(String[] args) {
    JFrame frame = new JFrame();

    // Settings for the Frame
    frame.setSize(400, 400);
    frame.setLayout(new MigLayout(""));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Parent panel which contains the panel to be docked east
    JPanel parentPanel = new JPanel(new MigLayout("", "[grow]", "[grow]"));

    // This is the panel which is docked east, it contains the panel (bottomPanel) with all the components
    // debug outlines the component (blue) , the cell (red) and the components within it (blue)
    JPanel easternDock = new JPanel(new MigLayout("debug, insets 0", "", "push[]")); 

    // Panel that contains all the components
    JPanel bottomPanel = new JPanel(new MigLayout());


    bottomPanel.add(new JButton("Button 1"), "wrap");
    bottomPanel.add(new JButton("Button 2"), "wrap");
    bottomPanel.add(new JButton("Button 3"), "wrap");

    easternDock.add(bottomPanel, "");

    parentPanel.add(easternDock, "east");

    frame.add(parentPanel, "push, grow");
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

}

}