Java Code Examples for java.awt.Window#getBounds()
The following examples show how to use
java.awt.Window#getBounds() .
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: InputContext.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private synchronized void notifyClientWindowChange(Window window) { if (inputMethod == null) { return; } // if the window is invisible or iconified, send null to the input method. if (!window.isVisible() || ((window instanceof Frame) && ((Frame)window).getState() == Frame.ICONIFIED)) { clientWindowLocation = null; inputMethod.notifyClientWindowChange(null); return; } Rectangle location = window.getBounds(); if (clientWindowLocation == null || !clientWindowLocation.equals(location)) { clientWindowLocation = location; inputMethod.notifyClientWindowChange(clientWindowLocation); } }
Example 2
Source File: InputContext.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private synchronized void notifyClientWindowChange(Window window) { if (inputMethod == null) { return; } // if the window is invisible or iconified, send null to the input method. if (!window.isVisible() || ((window instanceof Frame) && ((Frame)window).getState() == Frame.ICONIFIED)) { clientWindowLocation = null; inputMethod.notifyClientWindowChange(null); return; } Rectangle location = window.getBounds(); if (clientWindowLocation == null || !clientWindowLocation.equals(location)) { clientWindowLocation = location; inputMethod.notifyClientWindowChange(clientWindowLocation); } }
Example 3
Source File: InputContext.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private synchronized void notifyClientWindowChange(Window window) { if (inputMethod == null) { return; } // if the window is invisible or iconified, send null to the input method. if (!window.isVisible() || ((window instanceof Frame) && ((Frame)window).getState() == Frame.ICONIFIED)) { clientWindowLocation = null; inputMethod.notifyClientWindowChange(null); return; } Rectangle location = window.getBounds(); if (clientWindowLocation == null || !clientWindowLocation.equals(location)) { clientWindowLocation = location; inputMethod.notifyClientWindowChange(clientWindowLocation); } }
Example 4
Source File: InputContext.java From hottub with GNU General Public License v2.0 | 6 votes |
private synchronized void notifyClientWindowChange(Window window) { if (inputMethod == null) { return; } // if the window is invisible or iconified, send null to the input method. if (!window.isVisible() || ((window instanceof Frame) && ((Frame)window).getState() == Frame.ICONIFIED)) { clientWindowLocation = null; inputMethod.notifyClientWindowChange(null); return; } Rectangle location = window.getBounds(); if (clientWindowLocation == null || !clientWindowLocation.equals(location)) { clientWindowLocation = location; inputMethod.notifyClientWindowChange(clientWindowLocation); } }
Example 5
Source File: D3DGraphicsDevice.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Override protected void addFSWindowListener(Window w) { // if the window is not a toplevel (has an owner) we have to use the // real toplevel to enter the full-screen mode with (4933099). if (!(w instanceof Frame) && !(w instanceof Dialog) && (realFSWindow = getToplevelOwner(w)) != null) { ownerOrigBounds = realFSWindow.getBounds(); WWindowPeer fp = (WWindowPeer)realFSWindow.getPeer(); ownerWasVisible = realFSWindow.isVisible(); Rectangle r = w.getBounds(); // we use operations on peer instead of component because calling // them on component will take the tree lock fp.reshape(r.x, r.y, r.width, r.height); fp.setVisible(true); } else { realFSWindow = w; } fsWindowWasAlwaysOnTop = realFSWindow.isAlwaysOnTop(); ((WWindowPeer)realFSWindow.getPeer()).setAlwaysOnTop(true); fsWindowListener = new D3DFSWindowAdapter(); realFSWindow.addWindowListener(fsWindowListener); }
Example 6
Source File: InputContext.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
private synchronized void notifyClientWindowChange(Window window) { if (inputMethod == null) { return; } // if the window is invisible or iconified, send null to the input method. if (!window.isVisible() || ((window instanceof Frame) && ((Frame)window).getState() == Frame.ICONIFIED)) { clientWindowLocation = null; inputMethod.notifyClientWindowChange(null); return; } Rectangle location = window.getBounds(); if (clientWindowLocation == null || !clientWindowLocation.equals(location)) { clientWindowLocation = location; inputMethod.notifyClientWindowChange(clientWindowLocation); } }
Example 7
Source File: InputContext.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private synchronized void notifyClientWindowChange(Window window) { if (inputMethod == null) { return; } // if the window is invisible or iconified, send null to the input method. if (!window.isVisible() || ((window instanceof Frame) && ((Frame)window).getState() == Frame.ICONIFIED)) { clientWindowLocation = null; inputMethod.notifyClientWindowChange(null); return; } Rectangle location = window.getBounds(); if (clientWindowLocation == null || !clientWindowLocation.equals(location)) { clientWindowLocation = location; inputMethod.notifyClientWindowChange(clientWindowLocation); } }
Example 8
Source File: D3DGraphicsDevice.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Override protected void addFSWindowListener(Window w) { // if the window is not a toplevel (has an owner) we have to use the // real toplevel to enter the full-screen mode with (4933099). if (!(w instanceof Frame) && !(w instanceof Dialog) && (realFSWindow = getToplevelOwner(w)) != null) { ownerOrigBounds = realFSWindow.getBounds(); WWindowPeer fp = (WWindowPeer)realFSWindow.getPeer(); ownerWasVisible = realFSWindow.isVisible(); Rectangle r = w.getBounds(); // we use operations on peer instead of component because calling // them on component will take the tree lock fp.reshape(r.x, r.y, r.width, r.height); fp.setVisible(true); } else { realFSWindow = w; } fsWindowWasAlwaysOnTop = realFSWindow.isAlwaysOnTop(); ((WWindowPeer)realFSWindow.getPeer()).setAlwaysOnTop(true); fsWindowListener = new D3DFSWindowAdapter(); realFSWindow.addWindowListener(fsWindowListener); }
Example 9
Source File: SeaGlassRootPaneUI.java From seaglass with Apache License 2.0 | 6 votes |
/** * @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent) */ public void mouseDragged(MouseEvent ev) { Window w = (Window) ev.getSource(); Point pt = ev.getPoint(); if (isMovingWindow) { Point eventLocationOnScreen = ev.getLocationOnScreen(); w.setLocation(eventLocationOnScreen.x - dragOffsetX, eventLocationOnScreen.y - dragOffsetY); } else if (dragCursor != 0) { Rectangle r = w.getBounds(); Rectangle startBounds = new Rectangle(r); Dimension min = w.getMinimumSize(); switch (dragCursor) { case Cursor.E_RESIZE_CURSOR: adjust(r, min, 0, 0, pt.x + (dragWidth - dragOffsetX) - r.width, 0); break; case Cursor.S_RESIZE_CURSOR: adjust(r, min, 0, 0, 0, pt.y + (dragHeight - dragOffsetY) - r.height); break; case Cursor.N_RESIZE_CURSOR: adjust(r, min, 0, pt.y - dragOffsetY, 0, -(pt.y - dragOffsetY)); break; case Cursor.W_RESIZE_CURSOR: adjust(r, min, pt.x - dragOffsetX, 0, -(pt.x - dragOffsetX), 0); break; case Cursor.NE_RESIZE_CURSOR: adjust(r, min, 0, pt.y - dragOffsetY, pt.x + (dragWidth - dragOffsetX) - r.width, -(pt.y - dragOffsetY)); break; case Cursor.SE_RESIZE_CURSOR: adjust(r, min, 0, 0, pt.x + (dragWidth - dragOffsetX) - r.width, pt.y + (dragHeight - dragOffsetY) - r.height); break; case Cursor.NW_RESIZE_CURSOR: adjust(r, min, pt.x - dragOffsetX, pt.y - dragOffsetY, -(pt.x - dragOffsetX), -(pt.y - dragOffsetY)); break; case Cursor.SW_RESIZE_CURSOR: adjust(r, min, pt.x - dragOffsetX, 0, -(pt.x - dragOffsetX), pt.y + (dragHeight - dragOffsetY) - r.height); break; default: break; } if (!r.equals(startBounds)) { w.setBounds(r); // Defer repaint/validate on mouseReleased unless dynamic // layout is active. if (Toolkit.getDefaultToolkit().isDynamicLayoutActive()) { w.validate(); getRootPane().repaint(); } } } }
Example 10
Source File: D3DGraphicsDevice.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Override protected void addFSWindowListener(Window w) { // if the window is not a toplevel (has an owner) we have to use the // real toplevel to enter the full-screen mode with (4933099). if (!(w instanceof Frame) && !(w instanceof Dialog) && (realFSWindow = getToplevelOwner(w)) != null) { ownerOrigBounds = realFSWindow.getBounds(); WWindowPeer fp = (WWindowPeer)realFSWindow.getPeer(); ownerWasVisible = realFSWindow.isVisible(); Rectangle r = w.getBounds(); // we use operations on peer instead of component because calling // them on component will take the tree lock fp.reshape(r.x, r.y, r.width, r.height); fp.setVisible(true); } else { realFSWindow = w; } fsWindowWasAlwaysOnTop = realFSWindow.isAlwaysOnTop(); ((WWindowPeer)realFSWindow.getPeer()).setAlwaysOnTop(true); fsWindowListener = new D3DFSWindowAdapter(); realFSWindow.addWindowListener(fsWindowListener); }
Example 11
Source File: InputContext.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private synchronized void notifyClientWindowChange(Window window) { if (inputMethod == null) { return; } // if the window is invisible or iconified, send null to the input method. if (!window.isVisible() || ((window instanceof Frame) && ((Frame)window).getState() == Frame.ICONIFIED)) { clientWindowLocation = null; inputMethod.notifyClientWindowChange(null); return; } Rectangle location = window.getBounds(); if (clientWindowLocation == null || !clientWindowLocation.equals(location)) { clientWindowLocation = location; inputMethod.notifyClientWindowChange(clientWindowLocation); } }
Example 12
Source File: XDMFrame.java From xdm with GNU General Public License v2.0 | 6 votes |
public static GraphicsDevice getWindowDevice(Window window) { Rectangle bounds = window.getBounds(); return Arrays.asList(GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()).stream() // pick devices where window located .filter(d -> d.getDefaultConfiguration().getBounds().intersects(bounds)) // sort by biggest intersection square .sorted((f, s) -> Long.compare(// square(f.getDefaultConfiguration().getBounds().intersection(bounds)), square(s.getDefaultConfiguration().getBounds().intersection(bounds)))) // use one with the biggest part of the window .reduce((f, s) -> s) // // fallback to default device .orElse(window.getGraphicsConfiguration().getDevice()); }
Example 13
Source File: InputContext.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
private synchronized void notifyClientWindowChange(Window window) { if (inputMethod == null) { return; } // if the window is invisible or iconified, send null to the input method. if (!window.isVisible() || ((window instanceof Frame) && ((Frame)window).getState() == Frame.ICONIFIED)) { clientWindowLocation = null; inputMethod.notifyClientWindowChange(null); return; } Rectangle location = window.getBounds(); if (clientWindowLocation == null || !clientWindowLocation.equals(location)) { clientWindowLocation = location; inputMethod.notifyClientWindowChange(clientWindowLocation); } }
Example 14
Source File: InputContext.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private synchronized void notifyClientWindowChange(Window window) { if (inputMethod == null) { return; } // if the window is invisible or iconified, send null to the input method. if (!window.isVisible() || ((window instanceof Frame) && ((Frame)window).getState() == Frame.ICONIFIED)) { clientWindowLocation = null; inputMethod.notifyClientWindowChange(null); return; } Rectangle location = window.getBounds(); if (clientWindowLocation == null || !clientWindowLocation.equals(location)) { clientWindowLocation = location; inputMethod.notifyClientWindowChange(clientWindowLocation); } }
Example 15
Source File: InputContext.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
private synchronized void notifyClientWindowChange(Window window) { if (inputMethod == null) { return; } // if the window is invisible or iconified, send null to the input method. if (!window.isVisible() || ((window instanceof Frame) && ((Frame)window).getState() == Frame.ICONIFIED)) { clientWindowLocation = null; inputMethod.notifyClientWindowChange(null); return; } Rectangle location = window.getBounds(); if (clientWindowLocation == null || !clientWindowLocation.equals(location)) { clientWindowLocation = location; inputMethod.notifyClientWindowChange(clientWindowLocation); } }
Example 16
Source File: Screen.java From RipplePower with Apache License 2.0 | 5 votes |
/** * 获得Screen的画面边界 * * @return */ public Rectangle getBounds() { if (handler == null) { return null; } Window window = handler.getScene(); Rectangle bounds = window.getBounds(); Insets insets = window.getInsets(); return new Rectangle(bounds.x + insets.left, bounds.y + insets.top, bounds.width - (insets.left + insets.top), bounds.height - (insets.top + insets.bottom)); }
Example 17
Source File: UiUtils.java From pgptool with GNU General Public License v3.0 | 5 votes |
private static Pair<GraphicsDevice, GraphicsConfiguration> determineGraphicsDeviceByWindow( GraphicsEnvironment graphicsEnvironment, List<GraphicsDevice> graphicsDevices, Window window) { log.debug("determineGraphicsDeviceByWindow " + format(window.getBounds())); Rectangle windowBounds = window.getBounds(); int lastArea = 0; Pair<GraphicsDevice, GraphicsConfiguration> ret = null; for (int i = 0; i < graphicsDevices.size(); ++i) { GraphicsDevice graphicsDevice = graphicsDevices.get(i); log.debug("- Checking GraphicsDevice: " + format(i, graphicsDevice, graphicsDevice.getDefaultConfiguration())); GraphicsConfiguration[] graphicsConfigurations = graphicsDevice.getConfigurations(); Set<Rectangle> seen = new HashSet<>(); for (int j = 0; j < graphicsConfigurations.length; ++j) { GraphicsConfiguration graphicsConfiguration = graphicsConfigurations[j]; Rectangle graphicsBounds = graphicsConfiguration.getBounds(); if (!seen.add(graphicsBounds)) { continue; } log.debug(" - Checking GraphicsConfiguration: " + format(graphicsBounds)); Rectangle intersection = windowBounds.intersection(graphicsBounds); int area = intersection.width * intersection.height; if (area != 0 && area > lastArea) { lastArea = area; ret = Pair.of(graphicsDevice, graphicsConfiguration); } } } return ret; }
Example 18
Source File: Preferences.java From pdfxtk with Apache License 2.0 | 5 votes |
void grab(boolean setATime, Window w) { bounds = w.getBounds(); showing = w.isShowing(); if(w instanceof Frame) icon = ((Frame)w).getState() == Frame.ICONIFIED; if(setATime) activationTime = System.currentTimeMillis(); }
Example 19
Source File: AWTUtilitiesWrapper.java From gameserver with Apache License 2.0 | 5 votes |
public static Shape getWindowShape(Window window) { if (hasMethod(getWindowShape)) { try { return (Shape) getWindowShape.invoke(null, window); } catch (Exception e) { LOG.log(Level.FINE, "cant access windowOpacity", e); } } return window.getBounds(); }
Example 20
Source File: JavaHelp.java From netbeans with Apache License 2.0 | 4 votes |
/** If needed, visually rearrange dialogViewer and dlg on screen. * If they overlap, try to make them not overlap. * @param dlg the visible modal dialog * @param dialogOrFrameViewer The viewer, a dialog of a frame. */ private void rearrange(Dialog dlg, Window dialogOrFrameViewer) { Rectangle r1 = dlg.getBounds(); Rectangle r2 = dialogOrFrameViewer.getBounds(); if (r1.intersects(r2)) { Installer.log.fine("modal dialog and dialog viewer overlap"); Dimension s = Toolkit.getDefaultToolkit().getScreenSize(); int xExtra = s.width - r1.width - r2.width; int yExtra = s.height - r1.height - r2.height; if(xExtra >= yExtra){ //compare y axes of r1 and r2 to know how to relocate them - horizontal relocation int r1Yaxis = r1.x + (r1.width/2); int r2Yaxis = r2.x + (r2.width/2); if(r1Yaxis <= r2Yaxis) { Installer.log.fine(" send help to the right"); if((r1.x + r1.width + r2.width) <= s.width) { Installer.log.fine("there is enough place fo help"); r2.x = r1.x + r1.width; } else { Installer.log.fine("there is not enough place"); if((r1.width + r2.width) < s.width) { Installer.log.fine("relocate both"); r2.x = s.width - r2.width; r1.x = r2.x - r1.width; } else { Installer.log.fine("relocate both and resize help"); r1.x = 0; r2.x = r1.width; r2.width = s.width - r1.width; } } } else { Installer.log.fine("send help to the left"); if((r1.x - r2.width) > 0) { Installer.log.fine("there is enough place for help"); r2.x = r1.x - r2.width; } else { Installer.log.fine("there is not enough place"); if((r1.width + r2.width) < s.width){ Installer.log.fine("relocate both"); r2.x = 0; r1.x = r2.width; } else { Installer.log.fine("relocate both and resize help"); r1.x = s.width - r1.width; r2.x = 0; r2.width = r1.x; } } } } else { //compare x axes of r1 and r2 to know how to relocate them int r1Xaxis = r1.y + (r1.height/2); int r2Xaxis = r2.y + (r2.height/2); if(r1Xaxis <= r2Xaxis) { Installer.log.fine(" send help to the bottom"); if((r1.y + r1.height + r2.height) <= s.height) { Installer.log.fine("there is enough place fo help"); r2.y = r1.y + r1.height; } else { Installer.log.fine("there is not enough place"); if((r1.height + r2.height) < s.height) { Installer.log.fine("relocate both"); r2.y = s.height - r2.height; r1.y = r2.y - r1.height; } else { Installer.log.fine("relocate both and resize help"); r1.y = 0; r2.y = r1.height; r2.height = s.height - r1.height; } } } else { Installer.log.fine("send help to the top"); if((r1.y - r2.height) > 0){ Installer.log.fine("there is enough place for help"); r2.y = r1.y - r2.height; } else { Installer.log.fine("there is not enough place"); if((r1.height + r2.height) < s.height) { Installer.log.fine("relocate both"); r2.y = 0; r1.y = r2.height; } else { Installer.log.fine("relocate both and resize help"); r1.y = s.height - r1.height; r2.y = 0; //or with -1 r2.height = r1.y; } } } } dlg.setBounds(r1); dialogOrFrameViewer.setBounds(r2); } }