Getting the Child Components of a Container : Panel « Swing JFC « Java






Getting the Child Components of a Container

  

import java.awt.Component;
import java.awt.Rectangle;

import javax.swing.JFrame;

public class Main {
  public static void main() {

    JFrame container = new JFrame();

    Component[] components = container.getComponents();

    for (int i = 0; i < components.length; i++) {
      Rectangle bounds = components[i].getBounds();
    }

  }
}

   
    
  








Related examples in the same category

1.Panel with background imagePanel with background image
2.Retrieve all components individually:
3.Determining When a Component Is Added or Removed from a Container
4.Horizontal Split Pane based on JPanel