Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Tyring to reset JPanel's components

843806Apr 10 2008 — edited Apr 10 2008
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?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 8 2008
Added on Apr 10 2008
2 comments
680 views