List of usage examples for java.awt Window getHeight
public int getHeight()
From source file:Main.java
public static void centralizeWindow(Window window) { int windowWidth = window.getWidth(); int windowHeight = window.getHeight(); int screenWidth = (int) java.awt.Toolkit.getDefaultToolkit().getScreenSize().getWidth(); int screenHeight = (int) java.awt.Toolkit.getDefaultToolkit().getScreenSize().getHeight(); window.setBounds(screenWidth / 2 - windowWidth / 2, screenHeight / 2 - windowHeight / 2, windowWidth, windowHeight);/* ww w. java2s. com*/ }
From source file:Main.java
private static void centerWindow(Window w, Point center) { int x = center.x - w.getWidth() / 2; int y = center.y - w.getHeight() / 2; w.setLocation(x, y);/* ww w .j av a 2 s . co m*/ }
From source file:Main.java
/** * * @deprecated Use automatic RitDialog centering facilities *///from w w w .j a va 2 s. co m public static void centerWindowOnScreen(Window window) { Dimension dim = window.getToolkit().getScreenSize(); window.setLocation((dim.width - window.getWidth()) / 2, (dim.height - (window.getHeight())) / 2); }
From source file:Main.java
public static void centerWindow(Window w, Window reference) { Point refCorner = reference.getLocation(); Point center = new Point(refCorner.x + reference.getWidth() / 2, refCorner.y + reference.getHeight() / 2); centerWindow(w, center);// w ww . j av a2s.c om }
From source file:Main.java
/** * This method packs, sets the size, and sets the position of the window given * * @param window//ww w . ja va 2 s . com */ public static void centerAndPack(Window window) { window.pack(); int x = getWindowXCenter() - (window.getWidth() / 2); int y = getWindowYCenter() - (window.getHeight() / 2); window.setLocation(x, y); window.setMinimumSize(new Dimension(window.getWidth(), window.getHeight())); }
From source file:Main.java
/** * Centers a given window on the screen. * /*from w w w .j av a 2 s . co m*/ * @param window * The window, frame or dialog */ public static void centerOnScreen(Window window) { Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); int x = (int) ((d.getWidth() - window.getWidth()) / 2); int y = (int) ((d.getHeight() - window.getHeight()) / 2); window.setLocation(x, y); }
From source file:Main.java
public static void center(Window window) { Dimension screen = window.getToolkit().getScreenSize(); window.setLocation((screen.width - window.getWidth()) / 2, (screen.height - window.getHeight()) / 2); }
From source file:Main.java
/** * Centers a {@link Window} at the center of the screen.<br/> * Windows like {@link JDialog} and {@link JFrame} (and others) that extend from {@link Window} applies for this method. * // ww w . j a v a2 s . co m * @param window */ public static void centerWindow(Window window) { window.setLocation((Toolkit.getDefaultToolkit().getScreenSize().width) / 2 - window.getWidth() / 2, (Toolkit.getDefaultToolkit().getScreenSize().height) / 2 - window.getHeight() / 2); }
From source file:Main.java
public static void center(Window window) { window.pack();/*w w w .ja va 2 s . co m*/ Rectangle bounds = window.getGraphicsConfiguration().getBounds(); int width = window.getWidth(); int height = window.getHeight(); int centerX = bounds.x + bounds.width / 2; int centerY = bounds.y + bounds.height / 2; window.setLocation(centerX - width / 2, centerY - height / 2); window.setPreferredSize(new Dimension(width, height)); }
From source file:Main.java
/** * {@link Window#pack() Packs} the given window and positions it so that its * center stays the same.//from w ww.ja v a 2s .c om * * @param window * The window to pack and recenter */ public static void repackCentered(Window window) { Point center = getCenter(window.getBounds()); window.pack(); window.setLocation((center.x - window.getWidth() / 2), (center.y - window.getHeight() / 2)); window.repaint(); }