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

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

源代码1 项目: seaglass   文件: SeaGlassRootPaneUI.java
/**
 * Returns the corner that contains the point <code>x</code>, <code>
 * y</code>, or -1 if the position doesn't match a corner.
 *
 * @param  w the window.
 * @param  x the x coordinate.
 * @param  y the y coordinate.
 *
 * @return the corner containing the (x, y) coordinate, or -1 if the
 *         position doesn't match a corner.
 */
private int calculateCorner(Window w, int x, int y) {
    Insets insets    = w.getInsets();
    int    xPosition = calculatePosition(x - insets.left, w.getWidth() - insets.left - insets.right);
    int    yPosition = calculatePosition(y - insets.top, w.getHeight() - insets.top - insets.bottom);

    if (xPosition == -1 || yPosition == -1) {
        return -1;
    }

    return yPosition * 5 + xPosition;
}
 
源代码2 项目: lizzie   文件: WindowPosition.java
public static JSONArray getWindowPos(LizziePane pane) {
  JSONArray panePos = new JSONArray("[]");
  Window paneWindow = SwingUtilities.getWindowAncestor(pane);
  if (!(paneWindow instanceof LizzieMain)) {
    Insets insets = paneWindow.getInsets();
    panePos.put(paneWindow.getX());
    panePos.put(paneWindow.getY());
    panePos.put(paneWindow.getWidth() - insets.left - insets.right);
    panePos.put(paneWindow.getHeight() - insets.top - insets.bottom);
  }
  return panePos;
}
 
源代码3 项目: lizzie   文件: LizziePane.java
private int calculateCorner(Window c, int x, int y) {
  Insets insets = c.getInsets();
  int xPosition = calculatePosition(x - insets.left, c.getWidth() - insets.left - insets.right);
  int yPosition = calculatePosition(y - insets.top, c.getHeight() - insets.top - insets.bottom);

  if (xPosition == -1 || yPosition == -1) {
    return -1;
  }
  return yPosition * 5 + xPosition;
}
 
源代码4 项目: 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));
}
 
源代码5 项目: dragonwell8_jdk   文件: Util.java
public static Point getTitlePoint(Window decoratedWindow) {
    Point p = decoratedWindow.getLocationOnScreen();
    Dimension d = decoratedWindow.getSize();
    return new Point(p.x + (int)(d.getWidth()/2),
                     p.y + (int)(decoratedWindow.getInsets().top/2));
}
 
源代码6 项目: beautyeye   文件: BETitlePane.java
/**
	 * Renders the TitlePane.
	 *
	 * @param g the g
	 */
	public void paintComponent(Graphics g)
	{
		// As state isn't bound, we need a convenience place to check
		// if it has changed. Changing the state typically changes the
		if (getFrame() != null)
		{
			setState(getFrame().getExtendedState());
		}
		JRootPane rootPane = getRootPane();
		Window window = getWindow();
		boolean leftToRight = (window == null) ? rootPane
				.getComponentOrientation().isLeftToRight() : window
				.getComponentOrientation().isLeftToRight();
		boolean isSelected = (window == null) ? true : window.isActive();
		int width = getWidth();
		int height = getHeight();

		Color background;
		Color foreground;
		Color darkShadow;

		if (isSelected)
		{
			background = activeBackground;
			foreground = activeForeground;
			darkShadow = activeShadow;
		}
		else
		{
			background = inactiveBackground;
			foreground = inactiveForeground;
			darkShadow = inactiveShadow;
//			bumps = inactiveBumps;
		}
		//----------------------------------------------- 标题背景
		paintTitlePane(g,0,0,width,height,isSelected);

		//----------------------------------------------- 标题文字和图片
		int xOffset = leftToRight ? 5 : width - 5;

		if (getWindowDecorationStyle() == JRootPane.FRAME||getWindowDecorationStyle() ==JRootPane.PLAIN_DIALOG)
		{
			xOffset += leftToRight ? IMAGE_WIDTH + 5 : -IMAGE_WIDTH - 5;
		}

		String theTitle = getTitle();
		if (theTitle != null)
		{
			FontMetrics fm = MySwingUtilities2.getFontMetrics(rootPane, g);
			int yOffset = ((height - fm.getHeight()) / 2) + fm.getAscent();

			Rectangle rect = new Rectangle(0, 0, 0, 0);
			if (iconifyButton != null && iconifyButton.getParent() != null)
			{
				rect = iconifyButton.getBounds();
			}
			int titleW;

			if (leftToRight)
			{
				if (rect.x == 0)
				{
					rect.x = window.getWidth() - window.getInsets().right - 2;
				}
				titleW = rect.x - xOffset - 4;
				theTitle = MySwingUtilities2.clipStringIfNecessary(rootPane, fm,
						theTitle, titleW);
			}
			else
			{
				titleW = xOffset - rect.x - rect.width - 4;
				theTitle = MySwingUtilities2.clipStringIfNecessary(rootPane, fm,
						theTitle, titleW);
				xOffset -= MySwingUtilities2.stringWidth(rootPane, fm, theTitle);
			}
			
			int titleLength = MySwingUtilities2.stringWidth(rootPane, fm,theTitle);
			g.setColor(foreground);
			MySwingUtilities2.drawString(rootPane, g, theTitle, xOffset, yOffset);
			xOffset += leftToRight ? titleLength + 5 : -5;
		}
	}
 
源代码7 项目: TencentKona-8   文件: Util.java
public static Point getTitlePoint(Window decoratedWindow) {
    Point p = decoratedWindow.getLocationOnScreen();
    Dimension d = decoratedWindow.getSize();
    return new Point(p.x + (int)(d.getWidth()/2),
                     p.y + (int)(decoratedWindow.getInsets().top/2));
}
 
源代码8 项目: TencentKona-8   文件: FullScreenInsets.java
public static void main(final String[] args) {
    final GraphicsEnvironment ge = GraphicsEnvironment
            .getLocalGraphicsEnvironment();
    final GraphicsDevice[] devices = ge.getScreenDevices();

    final Window wGreen = new Frame();
    wGreen.setBackground(Color.GREEN);
    wGreen.setSize(300, 300);
    wGreen.setVisible(true);
    sleep();
    final Insets iGreen = wGreen.getInsets();
    final Dimension sGreen = wGreen.getSize();

    final Window wRed = new Frame();
    wRed.setBackground(Color.RED);
    wRed.setSize(300, 300);
    wRed.setVisible(true);
    sleep();
    final Insets iRed = wGreen.getInsets();
    final Dimension sRed = wGreen.getSize();

    for (final GraphicsDevice device : devices) {
        if (!device.isFullScreenSupported()) {
            continue;
        }
        device.setFullScreenWindow(wGreen);
        sleep();
        testWindowBounds(device.getDisplayMode(), wGreen);
        testColor(wGreen, Color.GREEN);

        device.setFullScreenWindow(wRed);
        sleep();
        testWindowBounds(device.getDisplayMode(), wRed);
        testColor(wRed, Color.RED);

        device.setFullScreenWindow(null);
        sleep();
        testInsets(wGreen.getInsets(), iGreen);
        testInsets(wRed.getInsets(), iRed);
        testSize(wGreen.getSize(), sGreen);
        testSize(wRed.getSize(), sRed);
    }
    wGreen.dispose();
    wRed.dispose();
    if (!passed) {
        throw new RuntimeException("Test failed");
    }
}
 
源代码9 项目: openjdk-8-source   文件: FullScreenInsets.java
public static void main(final String[] args) {
    final GraphicsEnvironment ge = GraphicsEnvironment
            .getLocalGraphicsEnvironment();
    final GraphicsDevice[] devices = ge.getScreenDevices();

    final Window wGreen = new Frame();
    wGreen.setBackground(Color.GREEN);
    wGreen.setSize(300, 300);
    wGreen.setVisible(true);
    sleep();
    final Insets iGreen = wGreen.getInsets();
    final Dimension sGreen = wGreen.getSize();

    final Window wRed = new Frame();
    wRed.setBackground(Color.RED);
    wRed.setSize(300, 300);
    wRed.setVisible(true);
    sleep();
    final Insets iRed = wGreen.getInsets();
    final Dimension sRed = wGreen.getSize();

    for (final GraphicsDevice device : devices) {
        if (!device.isFullScreenSupported()) {
            continue;
        }
        device.setFullScreenWindow(wGreen);
        sleep();
        testWindowBounds(device.getDisplayMode(), wGreen);
        testColor(wGreen, Color.GREEN);

        device.setFullScreenWindow(wRed);
        sleep();
        testWindowBounds(device.getDisplayMode(), wRed);
        testColor(wRed, Color.RED);

        device.setFullScreenWindow(null);
        sleep();
        testInsets(wGreen.getInsets(), iGreen);
        testInsets(wRed.getInsets(), iRed);
        testSize(wGreen.getSize(), sGreen);
        testSize(wRed.getSize(), sRed);
    }
    wGreen.dispose();
    wRed.dispose();
    if (!passed) {
        throw new RuntimeException("Test failed");
    }
}
 
源代码10 项目: lizzie   文件: GtpConsolePane.java
/** Creates a Gtp Console Window */
public GtpConsolePane(Window owner) {
  super(owner);
  setTitle("Gtp Console");

  JSONArray pos = WindowPosition.gtpWindowPos();
  if (pos != null) {
    this.setBounds(pos.getInt(0), pos.getInt(1), pos.getInt(2), pos.getInt(3));
  } else {
    Insets oi = owner.getInsets();
    setBounds(
        0,
        owner.getY() - oi.top,
        Math.max(owner.getX() - oi.left, 400),
        Math.max(owner.getHeight() + oi.top + oi.bottom, 300));
  }

  htmlKit = new LizziePane.HtmlKit();
  htmlDoc = (HTMLDocument) htmlKit.createDefaultDocument();
  htmlStyle = htmlKit.getStyleSheet();
  htmlStyle.addRule(Lizzie.config.gtpConsoleStyle);

  console = new JTextPane();
  console.setBorder(BorderFactory.createEmptyBorder());
  console.setEditable(false);
  console.setEditorKit(htmlKit);
  console.setDocument(htmlDoc);
  scrollPane = new JScrollPane();
  scrollPane.setBorder(BorderFactory.createEmptyBorder());
  txtCommand.setBackground(Color.DARK_GRAY);
  txtCommand.setForeground(Color.WHITE);
  lblCommand.setFont(new Font("Tahoma", Font.BOLD, 11));
  lblCommand.setOpaque(true);
  lblCommand.setBackground(Color.DARK_GRAY);
  lblCommand.setForeground(Color.WHITE);
  lblCommand.setText(Lizzie.leelaz == null ? "GTP>" : Lizzie.leelaz.currentShortWeight() + ">");
  pnlCommand.setLayout(new BorderLayout(0, 0));
  pnlCommand.add(lblCommand, BorderLayout.WEST);
  pnlCommand.add(txtCommand);
  getContentPane().add(scrollPane, BorderLayout.CENTER);
  getContentPane().add(pnlCommand, BorderLayout.SOUTH);
  scrollPane.setViewportView(console);
  getRootPane().setBorder(BorderFactory.createEmptyBorder());
  getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);

  txtCommand.addActionListener(e -> postCommand(e));
}
 
源代码11 项目: jdk8u-jdk   文件: Util.java
public static Point getTitlePoint(Window decoratedWindow) {
    Point p = decoratedWindow.getLocationOnScreen();
    Dimension d = decoratedWindow.getSize();
    return new Point(p.x + (int)(d.getWidth()/2),
                     p.y + (int)(decoratedWindow.getInsets().top/2));
}
 
源代码12 项目: openjdk-jdk8u   文件: FullScreenInsets.java
public static void main(final String[] args) {
    final GraphicsEnvironment ge = GraphicsEnvironment
            .getLocalGraphicsEnvironment();
    final GraphicsDevice[] devices = ge.getScreenDevices();

    final Window wGreen = new Frame();
    wGreen.setBackground(Color.GREEN);
    wGreen.setSize(300, 300);
    wGreen.setVisible(true);
    sleep();
    final Insets iGreen = wGreen.getInsets();
    final Dimension sGreen = wGreen.getSize();

    final Window wRed = new Frame();
    wRed.setBackground(Color.RED);
    wRed.setSize(300, 300);
    wRed.setVisible(true);
    sleep();
    final Insets iRed = wGreen.getInsets();
    final Dimension sRed = wGreen.getSize();

    for (final GraphicsDevice device : devices) {
        if (!device.isFullScreenSupported()) {
            continue;
        }
        device.setFullScreenWindow(wGreen);
        sleep();
        testWindowBounds(device.getDisplayMode(), wGreen);
        testColor(wGreen, Color.GREEN);

        device.setFullScreenWindow(wRed);
        sleep();
        testWindowBounds(device.getDisplayMode(), wRed);
        testColor(wRed, Color.RED);

        device.setFullScreenWindow(null);
        sleep();
        testInsets(wGreen.getInsets(), iGreen);
        testInsets(wRed.getInsets(), iRed);
        testSize(wGreen.getSize(), sGreen);
        testSize(wRed.getSize(), sRed);
    }
    wGreen.dispose();
    wRed.dispose();
    if (!passed) {
        throw new RuntimeException("Test failed");
    }
}
 
源代码13 项目: openjdk-8   文件: Util.java
public static Point getTitlePoint(Window decoratedWindow) {
    Point p = decoratedWindow.getLocationOnScreen();
    Dimension d = decoratedWindow.getSize();
    return new Point(p.x + (int)(d.getWidth()/2),
                     p.y + (int)(decoratedWindow.getInsets().top/2));
}
 
源代码14 项目: jdk8u_jdk   文件: FullScreenInsets.java
public static void main(final String[] args) {
    final GraphicsEnvironment ge = GraphicsEnvironment
            .getLocalGraphicsEnvironment();
    final GraphicsDevice[] devices = ge.getScreenDevices();

    final Window wGreen = new Frame();
    wGreen.setBackground(Color.GREEN);
    wGreen.setSize(300, 300);
    wGreen.setVisible(true);
    sleep();
    final Insets iGreen = wGreen.getInsets();
    final Dimension sGreen = wGreen.getSize();

    final Window wRed = new Frame();
    wRed.setBackground(Color.RED);
    wRed.setSize(300, 300);
    wRed.setVisible(true);
    sleep();
    final Insets iRed = wGreen.getInsets();
    final Dimension sRed = wGreen.getSize();

    for (final GraphicsDevice device : devices) {
        if (!device.isFullScreenSupported()) {
            continue;
        }
        device.setFullScreenWindow(wGreen);
        sleep();
        testWindowBounds(device.getDisplayMode(), wGreen);
        testColor(wGreen, Color.GREEN);

        device.setFullScreenWindow(wRed);
        sleep();
        testWindowBounds(device.getDisplayMode(), wRed);
        testColor(wRed, Color.RED);

        device.setFullScreenWindow(null);
        sleep();
        testInsets(wGreen.getInsets(), iGreen);
        testInsets(wRed.getInsets(), iRed);
        testSize(wGreen.getSize(), sGreen);
        testSize(wRed.getSize(), sRed);
    }
    wGreen.dispose();
    wRed.dispose();
    if (!passed) {
        throw new RuntimeException("Test failed");
    }
}
 
源代码15 项目: openjdk-jdk9   文件: Util.java
public static Point getTitlePoint(Window decoratedWindow) {
    Point p = decoratedWindow.getLocationOnScreen();
    Dimension d = decoratedWindow.getSize();
    return new Point(p.x + (int)(d.getWidth()/2),
                     p.y + (int)(decoratedWindow.getInsets().top/2));
}
 
源代码16 项目: openjdk-jdk9   文件: FullScreenInsets.java
public static void main(final String[] args) {
    final GraphicsEnvironment ge = GraphicsEnvironment
            .getLocalGraphicsEnvironment();
    final GraphicsDevice[] devices = ge.getScreenDevices();

    final Window wGreen = new Frame();
    wGreen.setBackground(Color.GREEN);
    wGreen.setSize(300, 300);
    wGreen.setVisible(true);
    sleep();
    final Insets iGreen = wGreen.getInsets();
    final Dimension sGreen = wGreen.getSize();

    final Window wRed = new Frame();
    wRed.setBackground(Color.RED);
    wRed.setSize(300, 300);
    wRed.setVisible(true);
    sleep();
    final Insets iRed = wGreen.getInsets();
    final Dimension sRed = wGreen.getSize();

    for (final GraphicsDevice device : devices) {
        if (!device.isFullScreenSupported()) {
            continue;
        }
        device.setFullScreenWindow(wGreen);
        sleep();
        testWindowBounds(device.getDisplayMode(), wGreen);
        testColor(wGreen, Color.GREEN);

        device.setFullScreenWindow(wRed);
        sleep();
        testWindowBounds(device.getDisplayMode(), wRed);
        testColor(wRed, Color.RED);

        device.setFullScreenWindow(null);
        sleep();
        testInsets(wGreen.getInsets(), iGreen);
        testInsets(wRed.getInsets(), iRed);
        testSize(wGreen.getSize(), sGreen);
        testSize(wRed.getSize(), sRed);
    }
    wGreen.dispose();
    wRed.dispose();
    if (!passed) {
        throw new RuntimeException("Test failed");
    }
}
 
源代码17 项目: jdk8u-jdk   文件: Util.java
public static Point getTitlePoint(Window decoratedWindow) {
    Point p = decoratedWindow.getLocationOnScreen();
    Dimension d = decoratedWindow.getSize();
    return new Point(p.x + (int)(d.getWidth()/2),
                     p.y + (int)(decoratedWindow.getInsets().top/2));
}
 
源代码18 项目: jdk8u-jdk   文件: FullScreenInsets.java
public static void main(final String[] args) {
    final GraphicsEnvironment ge = GraphicsEnvironment
            .getLocalGraphicsEnvironment();
    final GraphicsDevice[] devices = ge.getScreenDevices();

    final Window wGreen = new Frame();
    wGreen.setBackground(Color.GREEN);
    wGreen.setSize(300, 300);
    wGreen.setVisible(true);
    sleep();
    final Insets iGreen = wGreen.getInsets();
    final Dimension sGreen = wGreen.getSize();

    final Window wRed = new Frame();
    wRed.setBackground(Color.RED);
    wRed.setSize(300, 300);
    wRed.setVisible(true);
    sleep();
    final Insets iRed = wGreen.getInsets();
    final Dimension sRed = wGreen.getSize();

    for (final GraphicsDevice device : devices) {
        if (!device.isFullScreenSupported()) {
            continue;
        }
        device.setFullScreenWindow(wGreen);
        sleep();
        testWindowBounds(device.getDisplayMode(), wGreen);
        testColor(wGreen, Color.GREEN);

        device.setFullScreenWindow(wRed);
        sleep();
        testWindowBounds(device.getDisplayMode(), wRed);
        testColor(wRed, Color.RED);

        device.setFullScreenWindow(null);
        sleep();
        testInsets(wGreen.getInsets(), iGreen);
        testInsets(wRed.getInsets(), iRed);
        testSize(wGreen.getSize(), sGreen);
        testSize(wRed.getSize(), sRed);
    }
    wGreen.dispose();
    wRed.dispose();
    if (!passed) {
        throw new RuntimeException("Test failed");
    }
}
 
源代码19 项目: jdk8u-dev-jdk   文件: Util.java
public static Point getTitlePoint(Window decoratedWindow) {
    Point p = decoratedWindow.getLocationOnScreen();
    Dimension d = decoratedWindow.getSize();
    return new Point(p.x + (int)(d.getWidth()/2),
                     p.y + (int)(decoratedWindow.getInsets().top/2));
}
 
源代码20 项目: jdk8u_jdk   文件: Util.java
public static Point getTitlePoint(Window decoratedWindow) {
    Point p = decoratedWindow.getLocationOnScreen();
    Dimension d = decoratedWindow.getSize();
    return new Point(p.x + (int)(d.getWidth()/2),
                     p.y + (int)(decoratedWindow.getInsets().top/2));
}