java.awt.Window#getBounds ( )源码实例Demo

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

源代码1 项目: dragonwell8_jdk   文件: InputContext.java
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);
    }
}
 
源代码2 项目: TencentKona-8   文件: InputContext.java
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);
    }
}
 
源代码3 项目: openjdk-8-source   文件: InputContext.java
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);
    }
}
 
源代码4 项目: xdm   文件: XDMFrame.java
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());
}
 
源代码5 项目: jdk8u60   文件: InputContext.java
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);
    }
}
 
源代码6 项目: jdk8u60   文件: D3DGraphicsDevice.java
@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);
}
 
源代码7 项目: openjdk-jdk8u   文件: InputContext.java
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);
    }
}
 
源代码8 项目: jdk8u-jdk   文件: D3DGraphicsDevice.java
@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);
}
 
源代码9 项目: jdk8u-jdk   文件: InputContext.java
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);
    }
}
 
源代码10 项目: openjdk-jdk8u-backup   文件: D3DGraphicsDevice.java
@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);
}
 
源代码11 项目: hottub   文件: InputContext.java
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);
    }
}
 
源代码12 项目: openjdk-jdk9   文件: InputContext.java
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);
    }
}
 
源代码13 项目: jdk8u-jdk   文件: InputContext.java
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);
    }
}
 
源代码14 项目: openjdk-8   文件: InputContext.java
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);
    }
}
 
源代码15 项目: RipplePower   文件: Screen.java
/**
 * 获得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));
}
 
源代码16 项目: gameserver   文件: AWTUtilitiesWrapper.java
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();
}
 
源代码17 项目: pdfxtk   文件: Preferences.java
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();
   }
 
源代码18 项目: pgptool   文件: UiUtils.java
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;
}
 
源代码19 项目: seaglass   文件: SeaGlassRootPaneUI.java
/**
 * @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();
            }
        }
    }
}
 
源代码20 项目: netbeans   文件: JavaHelp.java
/** 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);
    }
}