Java Code Examples for javax.swing.SwingUtilities#getDeepestComponentAt()
The following examples show how to use
javax.swing.SwingUtilities#getDeepestComponentAt() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JLightweightFrame.java From Bytecoder with Apache License 2.0 | 6 votes |
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()); } }
Example 2
Source File: RendererPanel.java From netbeans with Apache License 2.0 | 5 votes |
@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); }
Example 3
Source File: JLightweightFrame.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
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()); } }
Example 4
Source File: JLightweightFrame.java From hottub with GNU General Public License v2.0 | 5 votes |
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()); } }
Example 5
Source File: MouseCapture.java From gcs with Mozilla Public License 2.0 | 5 votes |
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())); } }
Example 6
Source File: JLightweightFrame.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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()); } }
Example 7
Source File: JLightweightFrame.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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()); } }
Example 8
Source File: JLightweightFrame.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
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()); } }
Example 9
Source File: EditableHeaderUI.java From chipster with MIT License | 5 votes |
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); }
Example 10
Source File: ContextMenuHandler.java From marathonv5 with Apache License 2.0 | 5 votes |
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); }
Example 11
Source File: JLightweightFrame.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
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()); } }
Example 12
Source File: Device.java From marathonv5 with Apache License 2.0 | 5 votes |
public static Component getActiveComponent(Component component, int x, int y) { Component componentx = SwingUtilities.getDeepestComponentAt(component, x, y); if (componentx == null) { return component; } return componentx; }
Example 13
Source File: DragLayer.java From stendhal with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 14
Source File: BoxTabbedPaneUI.java From pumpernickel with MIT License | 5 votes |
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; }
Example 15
Source File: JLightweightFrame.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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()); } }
Example 16
Source File: AbstractListUI.java From netbeans with Apache License 2.0 | 4 votes |
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; }
Example 17
Source File: EditableTableHeaderUI.java From rapidminer-studio with GNU Affero General Public License v3.0 | 4 votes |
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); }
Example 18
Source File: BasicColorValuesCompletionItem.java From NBANDROID-V2 with Apache License 2.0 | 4 votes |
public static Component findComponentUnderMouse() { Window window = findWindow(); Point location = MouseInfo.getPointerInfo().getLocation(); SwingUtilities.convertPointFromScreen(location, window); return SwingUtilities.getDeepestComponentAt(window, location.x, location.y); }
Example 19
Source File: SwingTools.java From rapidminer-studio with GNU Affero General Public License v3.0 | 3 votes |
/** * 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; }
Example 20
Source File: AbstractDockingTest.java From ghidra with Apache License 2.0 | 3 votes |
/** * 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; }