javax.swing.SwingUtilities#getDeepestComponentAt ( )源码实例Demo

下面列出了javax.swing.SwingUtilities#getDeepestComponentAt ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Bytecoder   文件: JLightweightFrame.java
private void updateClientCursor() {
    PointerInfo pointerInfo = MouseInfo.getPointerInfo();
    if (pointerInfo == null) {
        /*
         * This can happen when multiple graphics device cannot decide
         * which graphics device contains the current mouse position
         * or on systems without a mouse
         */
         return;
    }
    Point p = pointerInfo.getLocation();
    SwingUtilities.convertPointFromScreen(p, this);
    Component target = SwingUtilities.getDeepestComponentAt(this, p.x, p.y);
    if (target != null) {
        content.setCursor(target.getCursor());
    }
}
 
源代码2 项目: TencentKona-8   文件: JLightweightFrame.java
private void updateClientCursor() {
    Point p = MouseInfo.getPointerInfo().getLocation();
    SwingUtilities.convertPointFromScreen(p, this);
    Component target = SwingUtilities.getDeepestComponentAt(this, p.x, p.y);
    if (target != null) {
        content.setCursor(target.getCursor());
    }
}
 
源代码3 项目: pumpernickel   文件: BoxTabbedPaneUI.java
public int getTabForCoordinate(int x, int y) {
	Component c = SwingUtilities.getDeepestComponentAt(tabs, x, y);
	while (c != tabs) {
		if (c instanceof JComponent) {
			JComponent jc = (JComponent) c;
			Integer i = (Integer) jc
					.getClientProperty(PROPERTY_TAB_INDEX);
			if (i != null)
				return i;
		}
		c = c.getParent();
	}
	return -1;
}
 
源代码4 项目: stendhal   文件: DragLayer.java
/**
 * Get the drop target capable of accepting the dragged entity at the
 * current location.
 *
 * @return drop target, or <code>null</code> if the component below is not a
 * 	DropTarget, or it is not capable of accepting the dragged entity
 */
private DropTarget getCurrentDropTarget() {
	if (underlyingComponent == null) {
		Container parent = getParent();
		Point containerPoint = SwingUtilities.convertPoint(this, point, parent);
		underlyingComponent = SwingUtilities.getDeepestComponentAt(parent, containerPoint.x, containerPoint.y);
	}
	if ((underlyingComponent instanceof DropTarget)
			&& (((DropTarget) underlyingComponent).canAccept(dragged.getEntity()))) {
		return (DropTarget) underlyingComponent;
	}
	return null;
}
 
源代码5 项目: marathonv5   文件: Device.java
public static Component getActiveComponent(Component component, int x, int y) {
    Component componentx = SwingUtilities.getDeepestComponentAt(component, x, y);
    if (componentx == null) {
        return component;
    }
    return componentx;
}
 
源代码6 项目: jdk8u_jdk   文件: JLightweightFrame.java
private void updateClientCursor() {
    Point p = MouseInfo.getPointerInfo().getLocation();
    SwingUtilities.convertPointFromScreen(p, this);
    Component target = SwingUtilities.getDeepestComponentAt(this, p.x, p.y);
    if (target != null) {
        content.setCursor(target.getCursor());
    }
}
 
源代码7 项目: marathonv5   文件: ContextMenuHandler.java
public void showPopup(MouseEvent mouseEvent) {
    if (isContextMenuOn()) {
        return;
    }
    Component component = SwingUtilities.getDeepestComponentAt(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
    if (component == null) {
        return;
    }
    if (component instanceof JMenuItem && (!(component instanceof JMenu) || ((JMenu) component).isSelected())) {
        return;
    }
    Point point = SwingUtilities.convertPoint(mouseEvent.getComponent(), mouseEvent.getPoint(), component);
    showPopup(component, point);
}
 
源代码8 项目: netbeans   文件: RendererPanel.java
@Override
public String getToolTipText(MouseEvent event) {
    Component c = SwingUtilities.getDeepestComponentAt(this, event.getX(), event.getY());
    if (c instanceof JComponent) {
        JComponent jc = (JComponent) c;
        String tooltip = jc.getToolTipText();
        if (null != tooltip) {
            return tooltip;
        }
    }
    return super.getToolTipText(event);
}
 
源代码9 项目: chipster   文件: EditableHeaderUI.java
private void setDispatchComponent(MouseEvent e) { 
	Component editorComponent = header.getEditorComponent();
	Point p = e.getPoint();
	Point p2 = SwingUtilities.convertPoint(header, p, editorComponent);
	dispatchComponent = SwingUtilities.getDeepestComponentAt(editorComponent, 
			p2.x, p2.y);
}
 
源代码10 项目: jdk8u-dev-jdk   文件: JLightweightFrame.java
private void updateClientCursor() {
    Point p = MouseInfo.getPointerInfo().getLocation();
    SwingUtilities.convertPointFromScreen(p, this);
    Component target = SwingUtilities.getDeepestComponentAt(this, p.x, p.y);
    if (target != null) {
        content.setCursor(target.getCursor());
    }
}
 
源代码11 项目: openjdk-jdk9   文件: JLightweightFrame.java
private void updateClientCursor() {
    Point p = MouseInfo.getPointerInfo().getLocation();
    SwingUtilities.convertPointFromScreen(p, this);
    Component target = SwingUtilities.getDeepestComponentAt(this, p.x, p.y);
    if (target != null) {
        content.setCursor(target.getCursor());
    }
}
 
源代码12 项目: jdk8u-jdk   文件: JLightweightFrame.java
private void updateClientCursor() {
    Point p = MouseInfo.getPointerInfo().getLocation();
    SwingUtilities.convertPointFromScreen(p, this);
    Component target = SwingUtilities.getDeepestComponentAt(this, p.x, p.y);
    if (target != null) {
        content.setCursor(target.getCursor());
    }
}
 
源代码13 项目: gcs   文件: MouseCapture.java
private void redispatchMouseEvent(MouseEvent event) {
    Point     glassPanePoint = event.getPoint();
    Point     containerPoint = SwingUtilities.convertPoint(mGlassPane, glassPanePoint, mCaptureComponent);
    Component component      = SwingUtilities.getDeepestComponentAt(mCaptureComponent, containerPoint.x, containerPoint.y);
    if (component != null) {
        Point componentPoint = SwingUtilities.convertPoint(mGlassPane, glassPanePoint, component);
        component.dispatchEvent(new MouseEvent(component, event.getID(), event.getWhen(), event.getModifiersEx(), componentPoint.x, componentPoint.y, event.getClickCount(), event.isPopupTrigger()));
    }
}
 
源代码14 项目: hottub   文件: JLightweightFrame.java
private void updateClientCursor() {
    Point p = MouseInfo.getPointerInfo().getLocation();
    SwingUtilities.convertPointFromScreen(p, this);
    Component target = SwingUtilities.getDeepestComponentAt(this, p.x, p.y);
    if (target != null) {
        content.setCursor(target.getCursor());
    }
}
 
源代码15 项目: openjdk-8   文件: JLightweightFrame.java
private void updateClientCursor() {
    Point p = MouseInfo.getPointerInfo().getLocation();
    SwingUtilities.convertPointFromScreen(p, this);
    Component target = SwingUtilities.getDeepestComponentAt(this, p.x, p.y);
    if (target != null) {
        content.setCursor(target.getCursor());
    }
}
 
源代码16 项目: rapidminer-studio   文件: EditableTableHeaderUI.java
private void setDispatchComponent(MouseEvent e) {
	Component editorComponent = header.getEditorComponent();
	Point p = e.getPoint();
	Point p2 = SwingUtilities.convertPoint(header, p, editorComponent);
	dispatchComponent = SwingUtilities.getDeepestComponentAt(editorComponent, p2.x, p2.y);
}
 
源代码17 项目: netbeans   文件: AbstractListUI.java
private boolean redispatchComponent(MouseEvent e) {
    Point p = e.getPoint();
    int index = list.locationToIndex(p);
    if (index < 0 || index >= list.getModel().getSize()) {
        return false;
    }

    ListCellRenderer renderer = list.getCellRenderer();
    if (null == renderer) {
        return false;
    }
    Component renComponent = renderer.getListCellRendererComponent(list, list.getModel().getElementAt(index), index, false, false);
    if (null == renComponent) {
        return false;
    }
    Rectangle rect = list.getCellBounds(index, index);
    if (null == rect) {
        return false;
    }
    renComponent.setBounds(0, 0, rect.width, rect.height);
    renComponent.doLayout();
    Point p3 = rect.getLocation();

    Point p2 = new Point(p.x - p3.x, p.y - p3.y);
    Component dispatchComponent =
            SwingUtilities.getDeepestComponentAt(renComponent,
            p2.x, p2.y);
    if ( e.isPopupTrigger() &&
         dispatchComponent instanceof LinkButton && 
         !((LinkButton)dispatchComponent).isHandlingPopupEvents() ) 
    {
        return false;
    } 
    if (dispatchComponent instanceof AbstractButton) {
        if (!((AbstractButton) dispatchComponent).isEnabled()) {
            return false;
        }
        Point p4 = SwingUtilities.convertPoint(renComponent, p2, dispatchComponent);
        MouseEvent newEvent = new MouseEvent(dispatchComponent,
                e.getID(),
                e.getWhen(),
                e.getModifiers(),
                p4.x, p4.y,
                e.getClickCount(),
                e.isPopupTrigger(),
                MouseEvent.NOBUTTON);
        dispatchComponent.dispatchEvent(newEvent);
        list.repaint(rect);
        e.consume();
        return true;
    }
    return false;
}
 
public static Component findComponentUnderMouse() {
    Window window = findWindow();
    Point location = MouseInfo.getPointerInfo().getLocation();
    SwingUtilities.convertPointFromScreen(location, window);
    return SwingUtilities.getDeepestComponentAt(window, location.x, location.y);
}
 
源代码19 项目: ghidra   文件: AbstractDockingTest.java
/**
 * Clicks the JComponent at the given point from within the given provider.
 *
 * @param provider The provider to be clicked.
 * @param button The mouse button to use (left, center, right)
 * @param x the x location of the click
 * @param y the y location of the click
 * @param clickCount the number of times to click
 * @param modifiers the modifiers to apply (Ctrl, Alt, etc; 0 is none)
 * @param popupTrigger true if this click should show a popup menu
 * @return the actual Java JComponent that was clicked
 */
public static Component clickComponentProvider(ComponentProvider provider, int button, int x,
		int y, int clickCount, int modifiers, boolean popupTrigger) {

	JComponent component = provider.getComponent();
	final Component clickComponent = SwingUtilities.getDeepestComponentAt(component, x, y);
	clickMouse(clickComponent, MouseEvent.BUTTON1, x, y, clickCount, modifiers, popupTrigger);
	return clickComponent;
}
 
源代码20 项目: rapidminer-studio   文件: SwingTools.java
/**
 * Returns <code>true</code> if the given {@link MouseEvent} only exited to child components of
 * the specified parent {@link Component}; <code>false</code> otherwise. This fixes the problem
 * that Swing triggers MouseExited events when moving the mouse for example over a button inside
 * the panel on which the mouse listener is.
 *
 * @param parent
 * @param e
 * @return
 */
public static boolean isMouseEventExitedToChildComponents(final Component parent, final MouseEvent e) {
	if (parent == null) {
		throw new IllegalArgumentException("parent must not be null!");
	}

	return SwingUtilities.getDeepestComponentAt(parent, e.getX(), e.getY()) != null;
}