Getting the Child Components of a Container
This example retrieves all of a container's children in an array:
This example retrieves all components individually:
// Get children
Component[] components = container.getComponents();
for (int i=0; i<components.length; i++) {
// Get the component's bounds
Rectangle bounds = components[i].getBounds();
}
// Get number of children
int count = container.getComponentCount();
for (int i=0; i<count; i++) {
Component c = container.getComponent(i);
}
Post a comment