#remove() doesn't delete JPanel in jswing
7 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @copper dagger! Please use
/closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
JPanel currentJPanel = panel.getOrderLinePanel();
currentJPanel.removeAll();
orderLinePanels.remove(panel);
remove(currentJPanel);
revalidate();
repaint();
I have checked the ID of the JPanel which gets assisgned to currentJPanel and it is the same as the one I am trying to delete. removeAll() works but the remove() does nothing.
From a code wise perspective everything should work as expected (assuming that this code is inside a class that JComponent). Are you sure that the panel isn't getting deleted ? You can check the component count of the container by using getComponentCount().
Does the number of components change ?
i suggest you remove current jpanel visibility before removing it like
currentJpanel.setVisible(false);
remove(currentJPanel)