Alp*_*ine 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
    }
});
Run Code Online (Sandbox Code Playgroud)

另请参见
如何使用按钮