Get Visible Child At : Container « Swing JFC « Java






Get Visible Child At

   

import java.awt.Component;
import java.awt.Container;
import java.awt.Point;


public class Util{
  
  public static final Component getVisibleChildAt(Container container, Point p) {
    for (int i = 0; i < container.getComponentCount(); i++) {
      Component c = container.getComponent(i);
      if (c.isVisible() && c.contains(p.x - c.getX(), p.y - c.getY()))
        return c;
    }

    return null;
  }

}

   
    
    
  








Related examples in the same category

1.Container Event DemoContainer Event Demo
2.ContainersContainers
3.Get Child At Line
4.Get Child At Point
5.Get Component Index
6.Get Visible Children Count
7.Find Component Under Glass Pane At
8.Find First Component Of Type
9.Count Components in a Container
10.Has Visible Children
11.Is Only Visible Component
12.Get All Components in a container
13.Container which can transform its children
14.Is Within Parent