2011-03-16 83 views

回答

21

尋找EventHandlingActionListener

或代碼?

JButton b = new JButton("Clear"); 
b.addActionListener(new ActionListener(){ 
    public void actionPerformed(ActionEvent e){ 
     textfield.setText(""); 
     //textfield.setText(null); //or use this 
    } 
}); 

請參見
How to Use Buttons

+0

非常感謝。 – Monte 2011-03-16 22:53:43