我正在尝试做问题的标题。我还没有想出办法来做到这一点。发生的事情是我输入的数值被更改为分配给我分配的变量的 int 值的值。我正在使用 textField 框来更改 JSplitPane 的 setDividerSize 属性的大小。也就是说,int newSize = 20 //默认的分隔线大小
jSplitPane.setDividerSize(newSize); //using the newSize variable
textField1.addActionListener (new ActionListener() {
public void actionPerformed(ActionEvent e) {
int newSize1 = new Integer(textField1.getText());
textField1.setText(new Integer(newSize).toString());
}
}); //method where I am trying to assign a new value to newSize to change
the width of the divider
如果我输入“5”,我会在 textField 框中得到“20”。
我试过这个:
newSize.setText(new Integer(textField1).toString());
但我得到一个错误:
cannot find symbol
symbol : constructor Integer(javax.swing.JTextField)
location: class java.lang.Integer
在网豆中。
有人可以帮帮我吗?我会很感激。如果这还不够代码,请告诉我,我将编辑原始帖子以包含它。谢谢你!