9
Duplicar posible:
JButton needs to change JTextfield textCómo limpiar el JTextField haciendo clic JButton
¿Cómo se borra un JTextField
cuando se hace clic en un JButton
?
Duplicar posible:
JButton needs to change JTextfield textCómo limpiar el JTextField haciendo clic JButton
¿Cómo se borra un JTextField
cuando se hace clic en un JButton
?
Buscando EventHandling, ActionListener?
¿o código?
JButton b = new JButton("Clear");
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
textfield.setText("");
//textfield.setText(null); //or use this
}
});
también vemos
How to Use Buttons
Muchas gracias. – Monte
mirada en respuesta a la pregunta vinculada en el comentario anterior. Puede borrar el texto configurando el texto en una cadena vacía. –