Position on Screen Right Bottom

后端 未结 2 982
星月不相逢
星月不相逢 2020-12-06 19:04

I need to position JFrame on my screen. But I can\'t make them appear on the right side of the screen bottom.

Please can someone explain me how to position them, if

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-06 20:02

    The easiest way I know is to nest JPanels each using its own layout manager.

    • The main JPanel would use a BorderLayout
    • Another JPanel that is added to the main at BorderLayout.SOUTH position also uses BorderLayout.
    • the component that needs to go at the SE corner is added to the above JPanel at the BorderLayout.EAST position.
    • In general, you're almost always better off using layout managers vs. trying to set absolute position of components.

提交回复
热议问题