Here you can find the source of resetControlsInAPanel(JPanel panel)
public static void resetControlsInAPanel(JPanel panel)
//package com.java2s; //License from project: Open Source License import javax.swing.*; import java.awt.*; public class Main { public static void resetControlsInAPanel(JPanel panel) { for (Component cmp : panel.getComponents()) { if (cmp instanceof JTextField) { ((JTextField) cmp).setText(""); }/*ww w . j a v a 2 s . c o m*/ if (cmp instanceof JTextArea) { ((JTextArea) cmp).setText(""); } if (cmp instanceof JComboBox) { ((JComboBox) cmp).setSelectedItem(null); } if (cmp instanceof JList) { ((JList) cmp).setSelectedValue(null, false); } if (cmp instanceof JTable) { ((JTable) cmp).getSelectionModel().clearSelection(); } if (cmp instanceof JPanel) { resetControlsInAPanel((JPanel) cmp); } } } }