} Point p = new Point(x,y); SwingUtilities.convertPointFromScreen(p, w); comp = SwingUtilities.getDeepestComponentAt(w, p.x, p.y); if(comp == w){ p = new Point(x,y); SwingUtilities.convertPointFromScreen(p, base); comp = SwingUtilities.getDeepestComponentAt(base, p.x, p.y);
Point p = new Point(x,y); SwingUtilities.convertPointFromScreen(p, w); comp = SwingUtilities.getDeepestComponentAt(w, p.x, p.y); if(comp == w){ p = new Point(x,y); SwingUtilities.convertPointFromScreen(p, base); comp = SwingUtilities.getDeepestComponentAt(base, p.x, p.y); }
    public Component getTopComponentAt(int x, int y) {        if(desktopFrame == null){            //no AWT yet, drop the event            return null;        }        Component comp = desktopFrame.getDesktop().getComponentAt(x,y);        if(comp instanceof SwingBaseWindow){            SwingBaseWindow base = (SwingBaseWindow) comp;            Window w = base.getAWTComponent();            if(w instanceof Frame){                MenuBar mb = ((Frame)w).getMenuBar();                if(mb != null){                    JMenuBar jmb = ((SwingMenuBarPeer)mb.getPeer()).jComponent;                    Point p = new Point(x,y);                    SwingUtilities.convertPointFromScreen(p, jmb);                    comp = SwingUtilities.getDeepestComponentAt(jmb, p.x, p.y);                    if(comp != null && (comp != jmb || comp == jmb && jmb.contains(p.x,p.y))){                        return comp;                    }                }            }            Point p = new Point(x,y);            SwingUtilities.convertPointFromScreen(p, w);            comp = SwingUtilities.getDeepestComponentAt(w, p.x, p.y);            if(comp == w){                p = new Point(x,y);                SwingUtilities.convertPointFromScreen(p, base);                comp = SwingUtilities.getDeepestComponentAt(base, p.x, p.y);            }        } else {            comp = super.getTopComponentAt(x, y);            SwingFrame sfp = (SwingFrame) SwingUtilities.getAncestorOfClass(                    SwingFrame.class, comp);            if (sfp != null) {                Rectangle r = sfp.getBounds();                Insets ins = sfp.getSwingPeer().getInsets();                r.x = r.x + ins.left;                r.y = r.y + ins.top;                r.width = r.width - ins.left - ins.right;                r.height = r.height - ins.top - ins.bottom;                if (r.contains(x, y)) {                    Component c = sfp.getAWTComponent().findComponentAt(x, y);                    if (c != null) {                        comp = c;                    }                }            }        }        return comp;    }