Is there are a method to clear the value of a Swing component. For example if we take the JTextField every time I want it to be cleared I have to call - txtField.setText("")
. I once made a utility method for these type of cases -
public static void clearFields(JComponent[] components) {
for (int i = 0; i < components.length; i++) {
JTextComponent jComponent = (JTextComponent) components[i];
jComponent.setText("");
}
}
I want to know if a better way is available in the Swing API itself. Or whether there is a way to refresh all the values in a JPanel.