Creating two buttons at bottom left/right corner

前端 未结 4 1122
梦谈多话
梦谈多话 2021-01-26 03:09
JButton button1 = new JButton(\"Button 1\");
JButton button2 = new JButton(\"Button 2\");
JFrame frame = new JFrame();
frame.getContentPane().setLayout(new BorderLayout(         


        
4条回答
  •  礼貌的吻别
    2021-01-26 03:26

    Create a container for both.

    JPanel south = new JPanel(new AxisLayout(AxisLayout.HORIZONTAL));
    south.add(button1);
    south.add(button2);
    frame.getContentPane().add(south, BorderLayout.SOUTH);
    

    Obs: Sorry dont remember exactly Swing layout manangers, but you will find the AxisLayout to solve this

提交回复
热议问题