Suggestion: ComponentContainer extends Iterable

Hi,

While working with TabSheet, I noticed it’s often useful to iterate over all the tabs. The current API requires the following because of the ComponentContainer interface:


TabSheet ts = new TabSheet();
... add tabs to ts, then tranverse:
Iterator<Component> i = ts.getComponentIterator();
while(i.hasNext()){
   Tab tab = ts.getTab(i.next());
   someProcessingOnTab(tab);
}

I was wondering if there’s any plan to add the Iterable interface, either to TabSheet or to ComponentContainer? If Iterable were added, the code can then be streamlined to this:


TabSheet ts = new TabSheet();
... add tabs to ts, then tranverse:
for(Component c: ts){
   Tab tab = ts.getTab(c);
   someProcessingOnTab(tab);
}

And more often than not, we actually want to work directly with the nested Component(s), in which case, the code is even cleaner:


TabSheet ts = new TabSheet();
... add tabs to ts, then tranverse:
for(Component c: ts){
   someProcessingOnComponent(c);
}

Adding the Iterable interface to each CompoenentContainer may be as simple as follows:


class SomeComponenetContainer implements Iterable<T extends Component> ...
{
   ...
   Iterator<T> iterator(){
      return getComponentIterator();
   }
}

Having ComponentContainer Implement Iterable seems to make sense, since getComponentIterator()'s aim appears to be to facilitate traversing through the child components, which can be done more fluently with Iterable and the for-each loop.

Just some thoughts, cheers.