How do I get a button to align to the right in MigLayout

久未见 提交于 2019-12-06 10:01:25

问题


I am adding a button to a panel using Miglayout, and try what I might, I cannot get it to go to the right end of the panel. It insists on going flush left. Oddly, the demo is kind of short on such on a example (it only shows it in the context of other buttons on the same panel.

I have a panel like this:

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

Except that it always insists on putting it like this:

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

回答1:


OK, I got the answer to this (finally). When adding the panel that contains the button add the component constraint of "gapbefore push." I had been trying that, but only on the button itself, not the panel.




回答2:


panel.add(button, "skip(the amount of cells you have), al 100%")



来源:https://stackoverflow.com/questions/3247497/how-do-i-get-a-button-to-align-to-the-right-in-miglayout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!