I have this code to get all the elements I need and do some processing. The problem is I need to specify every panel I have to get the elements inside it.
for (Component c : panCrawling.getComponents()) {
//processing
}
for (Component c : panFile.getComponents()) {
//processing
}
for (Component c : panThread.getComponents()) {
//processing
}
for (Component c : panLog.getComponents()) {
//processing
}
//continue to all panels
I want to do something like this and get all the elements without need specefy all the panels names. How I do this. The code below don't get all the elements.
for (Component c : this.getComponents()) {
//processing
}
Best Answer
You can write a recursive method and recurse on every container:
This site provides some sample code:
If you only want the components of the immediate sub-components, you could limit the recursion depth to 2.