Retrieve all components individually: : Panel « Swing JFC « Java

Retrieve all components individually:


import java.awt.Component;

import javax.swing.JFrame;

public class Main {
  public static void main(String[] argv) throws Exception {

    JFrame container = new JFrame();
    // Get number of children
    int count = container.getComponentCount();

    for (int i = 0; i < count; i++) {
      Component c = container.getComponent(i);


Related examples in the same category

1.Panel with background imagePanel with background image
2.Getting the Child Components of a Container
3.Determining When a Component Is Added or Removed from a Container
4.Horizontal Split Pane based on JPanel