开发者

How to clear the JTextField by clicking JButton [duplicate]

This question already has answers here: Closed 10 years ago.开发者_如何学编程

Possible Duplicate:

JButton needs to change JTextfield text

How do I clear a JTextField when a JButton is clicked?


Looking for EventHandling, ActionListener?

or code?

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

Also See
How to Use Buttons

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜