【发布时间】:2017-03-22 08:52:46
【问题描述】:
我怎样才能使按钮的高度更大一些,并且左右列的宽度相同。我试过weightxweightyheightxheighty,但没用。提前致谢。这是我的代码:
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);
按钮定义的代码更多,但它只是将自己定位在布局上。
【问题讨论】:
标签: java awt layout-manager gridbaglayout