We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Greetings
I am in the need of iterating through all children of a Gpanel. The thing is that I need to check if certain children inside of it does already exists so as not to add it again. Is it possible to implement? I haven't found anything regarding children iteration in the Gpanel docs.
Regards
Answers
G4P does not allow you to iterate through the children of a GPanel (or any other window or control).
Since your program is responsible for adding controls to a GPanel it is simple enough to remember these controls in a separate list.
ArrayList<GAbstractControl> controlsOnPanel = new ArrayList<GAbstractControl>();
If you have a GPanel called
panel
and you add a control calledcontrol
to the panel you also add it to the list like thisSo to find out if a control is on the panel then you just have to see if it's in the list
controlsOnPanel
GAbstractControl
is the base class for all G4P controls so you can add sliders, buttons, textfields etcThanks quark. I was considering this approach too, in case of not having a method to get the panel's children. I will do it with a list :)