如何使按鈕高度稍大一些,左右列的寬度大小相同。我試過weightx
weighty
heightx
heighty
但它沒有工作。提前致謝。這裏是我的代碼:Java - 調整GridBagLayout中的按鈕大小
Container contentPane = getContentPane();
contentPane.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.insets = new Insets(20,20,20,20);
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1.0;
JButton back = new JButton("Back to previous menu");
c.gridx = 1;
c.gridy = 0;
contentPane.add(back,c);
JLabel welcome = new JLabel("Hi secretary, please select an action");
c.gridx = 0;
c.gridy = 0;
contentPane.add(welcome,c);
還有更多的按鈕定義代碼,但它只是將自己定位在佈局上。