如何通过单击JButton清除JTextField [英] How to clear the JTextField by clicking JButton
本文介绍了如何通过单击JButton清除JTextField的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
JButton需要更改JTextfield文本
Possible Duplicate:
JButton needs to change JTextfield text
当单击JButton
时如何清除JTextField
?
推荐答案
寻找 ActionListener ?
还是代码?
JButton b = new JButton("Clear");
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
textfield.setText("");
//textfield.setText(null); //or use this
}
});
也请参见
如何使用按钮
这篇关于如何通过单击JButton清除JTextField的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文