2
使用此代碼按鈕左對齊,但膠水不擴展..我想讓按鈕2和3向右浮動。液體佈局..使按鈕浮動右邊
frame = new JFrame();
frame.setBounds(100, 100, 450, 300);
JPanel panelBottom = new JPanel();
frame.getContentPane().add(panelBottom, BorderLayout.SOUTH);
panelBottom.setLayout(new FlowLayout(FlowLayout.LEFT));
JButton btnNewButton = new JButton("1");
panelBottom.add(btnNewButton);
Component glue = Box.createGlue();
panelBottom.add(glue);
JButton btnNewButton_1 = new JButton("2");
panelBottom.add(btnNewButton_1);
JButton btnNewButton_2 = new JButton("3");
panelBottom.add(btnNewButton_2);
今天我太慢了! 1 + –
或者實例化['Box'](http://download.oracle.com/javase/7/docs/api/javax/swing/Box.html)。 – trashgod