Java Code Examples for java.awt.Window#getInsets()
The following examples show how to use
java.awt.Window#getInsets() .
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: 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 2
Source File: SeaGlassRootPaneUI.java From seaglass with Apache License 2.0 | 5 votes |
/** * 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; }
Example 3
Source File: WindowPosition.java From lizzie with GNU General Public License v3.0 | 5 votes |
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; }
Example 4
Source File: LizziePane.java From lizzie with GNU General Public License v3.0 | 5 votes |
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; }
Example 5
Source File: FullScreenInsets.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
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"); } }
Example 6
Source File: Util.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
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)); }
Example 7
Source File: Util.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
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)); }
Example 8
Source File: FullScreenInsets.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
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"); } }
Example 9
Source File: Util.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
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)); }
Example 10
Source File: FullScreenInsets.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
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"); } }
Example 11
Source File: Util.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
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)); }
Example 12
Source File: FullScreenInsets.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
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"); } }
Example 13
Source File: Util.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
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)); }
Example 14
Source File: Util.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
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)); }
Example 15
Source File: Util.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
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)); }
Example 16
Source File: GtpConsolePane.java From lizzie with GNU General Public License v3.0 | 4 votes |
/** 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)); }
Example 17
Source File: FullScreenInsets.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
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"); } }
Example 18
Source File: FullScreenInsets.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
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"); } }
Example 19
Source File: Util.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
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)); }
Example 20
Source File: BETitlePane.java From beautyeye with Apache License 2.0 | 4 votes |
/** * 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; } }