setText("abc");
getText();
你需要添加一个监听器,在某种事件下去获取文本框的值:
添加监听器:xxx.addActionListener(new addListener());
xxx是一个组件例如Button之类的:
如:JButton button=new JButton(“OK”);;
监听器大致是这样:
class addListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand() == "OK") {
String error=error.getText().trim();
}
}
}
希望能帮到你
用.getText();
有没有text版的,可以复制粘贴的那种。