如果点击JTextField
时如何清除JButton
?
答案 0 :(得分:23)
正在寻找EventHandling,ActionListener?
或代码?
JButton b = new JButton("Clear");
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
textfield.setText("");
//textfield.setText(null); //or use this
}
});