How do I remove a JPanel (or any other JComponent) from a CardLayout?
I do not have direct access to the Component I want to remove, but I have the index (the one used to show the Panel, when we call cardLayout.show(parentComponent, index);).
How do I remove a JPanel (or any other JComponent ) from a CardLayout
Share
When you say index, you mean the name (String) of the component when it was inserted, right?
I don’t know any elegant way to do this, but you can try to get all the components in this container (parentComponent) and try to find the one that has the same name as your index. For example: