Java Code Examples for java.awt.Component#contains()
The following examples show how to use
java.awt.Component#contains() .
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: FlatInspector.java From FlatLaf with Apache License 2.0 | 5 votes |
private Component getDeepestComponentAt( Component parent, int x, int y ) { if( !parent.contains( x, y ) ) return null; if( parent instanceof Container ) { for( Component child : ((Container)parent).getComponents() ) { if( child == null || !child.isVisible() ) continue; int cx = x - child.getX(); int cy = y - child.getY(); Component c = (child instanceof Container) ? getDeepestComponentAt( child, cx, cy ) : child.getComponentAt( cx, cy ); if( c == null || !c.isVisible() ) continue; // ignore highlight figure and tooltip if( c == highlightFigure || c == tip ) continue; // ignore glass pane if( c.getParent() instanceof JRootPane && c == ((JRootPane)c.getParent()).getGlassPane() ) continue; if( "com.formdev.flatlaf.ui.FlatWindowResizer".equals( c.getClass().getName() ) ) continue; return c; } } return parent; }
Example 2
Source File: ComponentDetailsProvider.java From netbeans with Apache License 2.0 | 5 votes |
static Component componentAt(Component comp, int x, int y) { if (!comp.contains(x, y)) return null; if (comp instanceof Container) { for (Component c : ((Container)comp).getComponents()) { if (c != null && c.isVisible()) { Component at = componentAt(c, x - c.getX(), y - c.getY()); if (at != null) return at; } } } return comp; }
Example 3
Source File: ComponentDetailsProvider.java From visualvm with GNU General Public License v2.0 | 5 votes |
static Component componentAt(Component comp, int x, int y) { if (!comp.contains(x, y)) return null; if (comp instanceof Container) { for (Component c : ((Container)comp).getComponents()) { if (c != null && c.isVisible()) { Component at = componentAt(c, x - c.getX(), y - c.getY()); if (at != null) return at; } } } return comp; }
Example 4
Source File: DragAndDropReorderPane.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
private Component getDefaultLayerComponentAt(Point point) { for (Component component : getComponentsInLayer(DEFAULT_LAYER)) { if (component.contains(point.x - component.getX(), point.y - component.getY())) { return component; } } return null; }
Example 5
Source File: LuckBorderFocusHandle.java From littleluck with Apache License 2.0 | 5 votes |
@Override public void mouseExited(MouseEvent e) { Component source = (Component) e.getSource(); if (isLuckLineBorder() && !source.contains(e.getPoint())) { handleFocusLost(); } }
Example 6
Source File: GuiHelper.java From binnavi with Apache License 2.0 | 5 votes |
public static Component findComponentAt(final Container c, final Point sp) { final Point cp = new Point(sp.x, sp.y); SwingUtilities.convertPointFromScreen(cp, c); if (!c.contains(cp.x, cp.y)) { return c; } final int ncomponents = c.getComponentCount(); final Component component[] = c.getComponents(); for (int i = 0; i < ncomponents; i++) { final Component comp = component[i]; final Point loc = comp.getLocation(); if ((comp.contains(cp.x - loc.x, cp.y - loc.y)) && (comp.isVisible() == true)) { // found a component that intersects the point, see if there // is a deeper possibility. if (comp instanceof Container) { final Container child = (Container) comp; final Component deeper = findComponentAt(child, sp); if (deeper != null) { return deeper; } } else { return comp; } } } return c; }
Example 7
Source File: GraphPanel.java From pdfxtk with Apache License 2.0 | 5 votes |
private Component locationToComponent(int x, int y) { synchronized (getTreeLock()) { Component[] components = getComponents(); for(int i = 0; i < components.length; i++) { Component comp = components[i]; if(comp != null && comp != editor) if (comp.contains(x - comp.getX(), y - comp.getY())) return comp; } } return null; }
Example 8
Source File: DnDSupport.java From netbeans with Apache License 2.0 | 4 votes |
private boolean isInToolbarPanel( Point p ) { Component c = ToolbarPool.getDefault(); SwingUtilities.convertPointFromScreen( p, c ); return c.contains( p ); }
Example 9
Source File: JWindowToolBarUI.java From pdfxtk with Apache License 2.0 | 4 votes |
public boolean canDock(Component c, Point p) { // System.out.println("Can Dock: " + p); return c.contains(p); }