Java 如何使按钮在布局中向右对齐

Java 如何使按钮在布局中向右对齐,java,swing,miglayout,Java,Swing,Miglayout,我正在使用Miglayout将一个按钮添加到面板中,并尝试我所能做的,但我无法使它转到面板的右端。它坚持向左转。奇怪的是,这个演示在这样一个示例中有点短(它只在同一面板上的其他按钮的上下文中显示) 我有一个这样的小组: dialog ->complex display retrieved from another class OK Button here. dialo

我正在使用Miglayout将一个按钮添加到面板中,并尝试我所能做的,但我无法使它转到面板的右端。它坚持向左转。奇怪的是,这个演示在这样一个示例中有点短(它只在同一面板上的其他按钮的上下文中显示)

我有一个这样的小组:

    dialog
      ->complex display retrieved from another class
                                               OK Button here.
    dialog
      ->complex display retrieved from another class
    OK Button here.
除了它总是坚持这样说:

    dialog
      ->complex display retrieved from another class
                                               OK Button here.
    dialog
      ->complex display retrieved from another class
    OK Button here.

好的,我终于找到了答案。在添加包含按钮的面板时,添加组件约束“按下前间隙”。我一直在尝试,但只在按钮本身上,而不是面板上。添加(按钮,“跳过(单元格数量),al 100%”

面板。添加(按钮,“跳过(单元格数量)”