0

我想在 GridBagLayout 中链接 2 个单元格。我使用 Netbeans,所以我用 JAppletForm 编写。

JTextField dodawanyTextField = new javax.swing.JTextField();

dodawanyTextField.setText(nazwaLekcjiTextField.getText());

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridwidth = 2;
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 2;

jPanel3.add(dodawanyTextField, gridBagConstraints);

但它不起作用。

4

1 回答 1

1

调整您的GridBagConstraint's weightxandfill使组件沿 x 轴扩展:

gridBagConstraints.weightx = 1;
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
于 2013-06-05T22:00:31.760 回答