I have a JPanel called parentPanel.
Also I have other sonPanels in parentPanel.
I want to remove the sonPanels and add them in an arraylist<JPanel>
Can you help me??
Thanks in advance!!! 🙂
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Since JPanel inherits from Container, you can use the getComponents() method to get the list of your sonPanels.
After getting them all, you can clear you parentPanel by calling the removeAll() method.
If you had a
deleteRowsmethod, simply call the first method on yourJPanel, lets call itcontentPane, and then call the second method to remove.If you need to traverse even more deeply into each of the JPanels, you would need to, recursively do so.