public static Rectangle getScreenBoundsAt(Point pos) { GraphicsDevice gd = getGraphicsDeviceAt(pos); Rectangle bounds = null; if (gd != null) { bounds = gd.getDefaultConfiguration() .getBounds(); } return bounds; }
/** * have to adjust for offsets when the window-manager has a toolbar that consumes space and prevents overlap. * * this is only done on the 2nd popup is added to the list */ void calculateOffset(final boolean showFromTop, final int anchorX, final int anchorY) { if (offsetY == 0) { Point point = new Point(anchorX, anchorY); GraphicsConfiguration gc = ScreenUtil.getGraphicsDeviceAt(point) .getDefaultConfiguration(); Insets screenInsets = Toolkit.getDefaultToolkit() .getScreenInsets(gc); if (showFromTop) { if (screenInsets.top > 0) { offsetY = screenInsets.top - LookAndFeel.MARGIN; } } else { if (screenInsets.bottom > 0) { offsetY = screenInsets.bottom + LookAndFeel.MARGIN; } } } }
public static void showOnSameScreenAsMouse_Center(final Container frame) { Point mouseLocation = MouseInfo.getPointerInfo() .getLocation(); GraphicsDevice deviceAtMouse = ScreenUtil.getGraphicsDeviceAt(mouseLocation); Rectangle bounds = deviceAtMouse.getDefaultConfiguration() .getBounds(); frame.setLocation(bounds.x + bounds.width / 2 - frame.getWidth() / 2, bounds.y + bounds.height / 2 - frame.getHeight() / 2); }
public static void showOnSameScreenAsMouse(final Container frame) { Point mouseLocation = MouseInfo.getPointerInfo() .getLocation(); GraphicsDevice deviceAtMouse = ScreenUtil.getGraphicsDeviceAt(mouseLocation); frame.setLocation(deviceAtMouse.getDefaultConfiguration() .getBounds().x, frame.getY()); }
.getLocation(); device = ScreenUtil.getGraphicsDeviceAt(mouseLocation);
idAndPosition = ScreenUtil.getGraphicsDeviceAt(point) + ":" + position; } else { idAndPosition = parent.getName() + ":" + position;