Component child = parent.getComponentAt( x, y );
Component child = parent; if ( !parent.contains( x, y ) ) { child = null; } else { synchronized ( parent.getTreeLock() ) { if ( parent instanceof Container ) { Container container = (Container) parent; int ncomponents = container.getComponentCount(); for ( int i = 0; i < ncomponents; i++ ) { Component comp = container.getComponent( i ); if ( comp != null && comp.isVisible() && comp.contains( x - comp.getX(), y - comp.getY() ) ) { child = comp; break; } } } } }
    private Component componentAt( int x, int y, Component parent, boolean scanRootPanes ) {        //FIX ME: invisible components draggable?        if ( scanRootPanes && parent instanceof JRootPane ) {            JRootPane rootPane = (JRootPane) parent;            parent = rootPane.getContentPane();        }        Component child = parent.getComponentAt( x, y );        if ( child != null ) {            if ( parent instanceof JTabbedPane && child != parent ) {                child = ( (JTabbedPane) parent ).getSelectedComponent();            }            x -= child.getX();            y -= child.getY();        }        return child != parent && child != null ? componentAt( x, y, child, scanRootPanes ) : child;    }