how to clear text field in java gui code example
Example 1: clear text field in java
btnClear.addSelectionListener(new SelectionAdapter()
{
@Override
public void widgetSelected(SelectionEvent e)
{
textBox1.setText("");
textBox2.setText("");
}
});
Example 2: how to clear text fields in java
JButton b = new JButton("Clear");
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
textfield.setText("");
//textfield.setText(null); //or use this
}
});