I have a JButton and when I push it, it has to clear all the content in a JTextfield. How can I do this? Maybe there exists a method to clear a JTextfield or do I have to set the field to null?
I have a JButton and when I push it, it has to clear all
Share
The
JTextField#setTextmethod should do it with an emptyStringas text.As for reacting on the
JButtonclick, attach anActionListenerto it. The Swing tutorials illustrate this all in great detail.