hi all, i have a jpanel with jlabels added. i would like to change the panels content. unfortunately the old labels don't disappear. how can i clear the panel properly? this is my attempt which is not working:
i took a look at the cardLayout but i'm not sure if it is the thing i need. i don't have a fixed number of JLabels which are exchanged, but JLabels are dynamically created (dependend of where the user clicks) and attached. everytime the user clicks, the panel should be cleared and a new set of Jlabels should be created and attached to the panel.for this purpose it seems rather complicated to me to use cardLayout.
the second proposal is not working, same problem as before... i wonder why the panels content is not cleared by validate() or revalidate()?