I am trying to reset one particular JPanel in my application. The panel consists of components like JLabel and JCheckboxes. I tried removing the panel and adding a new one as below. But nothing changes in the UI. What might be the problem?
private void clear() {
getContentPane().remove(testPanel);
testPanel = new JPanel();
getContentPane().add(testPanel);
}
Or do I have to remove component by component in the testPanel to reset it?