Java, how can I reset JTextField

vedran picture vedran · Mar 21, 2012 · Viewed 9.1k times · Source

I made a simple search gui method to search for products in DB and it works flawlessly. However, after the search is done I'd like to reset (JTextFields which are used to get parameters of search) to blank. Is there a method to do this without invoking another instance?

Answer

Owais Qureshi picture Owais Qureshi · Mar 21, 2012

How about setting text content to empty strings,like this

myTextField.setText("");

And further more I think you might need a class which is inherited from JTextField and you can add all sorts of methods,Getters and setters in it (such as Clear() ) which may assists you and meets your needs..