Here you can find the source of getDeepestComponentAt(final MouseEvent aEvent)
parent
that contains the location x
, y
.
Parameter | Description |
---|---|
aParent | the root component to begin the search |
aXpos | the x target location |
aYpos | the y target location |
public static JComponent getDeepestComponentAt(final MouseEvent aEvent)
//package com.java2s; /*/*from w w w . java2s. c o m*/ * OpenBench LogicSniffer / SUMP project * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110, USA * * * Copyright (C) 2010-2011 - J.W. Janssen, http://www.lxtreme.nl */ import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Main { /** * Returns the deepest visible descendent Component of <code>parent</code> * that contains the location <code>x</code>, <code>y</code>. If * <code>parent</code> does not contain the specified location, then * <code>null</code> is returned. If <code>parent</code> is not a container, * or none of <code>parent</code>'s visible descendents contain the specified * location, <code>parent</code> is returned. * * @param aParent * the root component to begin the search * @param aXpos * the x target location * @param aYpos * the y target location */ public static JComponent getDeepestComponentAt(final Component aParent, final int aXpos, final int aYpos) { return (JComponent) SwingUtilities.getDeepestComponentAt(aParent, aXpos, aYpos); } /** * Returns the deepest visible descendent Component of <code>parent</code> * that contains the location <code>x</code>, <code>y</code>. If * <code>parent</code> does not contain the specified location, then * <code>null</code> is returned. If <code>parent</code> is not a container, * or none of <code>parent</code>'s visible descendents contain the specified * location, <code>parent</code> is returned. * * @param aParent * the root component to begin the search * @param aXpos * the x target location * @param aYpos * the y target location */ public static JComponent getDeepestComponentAt(final MouseEvent aEvent) { return getDeepestComponentAt(aEvent.getComponent(), aEvent.getX(), aEvent.getY()); } }