List of usage examples for javax.swing JFrame getSize
public Dimension getSize()
From source file:Main.java
public static void centerFrame(JFrame frame) { Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation(dim.width / 2 - frame.getSize().width / 2, dim.height / 2 - frame.getSize().height / 2); }
From source file:Main.java
public static void setCenterOfParent(JFrame parent, JDialog dialog) { Point parentPosition = parent.getLocation(); Dimension parentSize = parent.getSize(); Dimension size = dialog.getSize(); Point position = new Point(parentPosition.x + (parentSize.width / 2 - size.width / 2), parentPosition.y + (parentSize.height / 2 - size.height / 2)); dialog.setLocation(position);//ww w . j a v a 2 s .c o m }
From source file:Main.java
static void setFramePositon(JFrame inTargetFrame) { Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); Dimension size = inTargetFrame.getSize(); // (ulrivo): full size on screen with less than 640 width if (d.width >= 640) { inTargetFrame.setLocation((d.width - size.width) / 2, (d.height - size.height) / 2); } else {/*from w ww . j a va 2 s . c o m*/ inTargetFrame.setLocation(0, 0); inTargetFrame.setSize(d); } }
From source file:Main.java
public static void centerFrame(JFrame frame) { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = frame.getSize(); frame.setLocation((screenSize.width / 2) - (frameSize.width / 2), (screenSize.height / 2) - (frameSize.height / 2)); }
From source file:Main.java
/** * Position in center a JFrame// www . j av a2 s. c o m * * @param jFrame */ public static void center(JFrame jFrame) { Toolkit tk = Toolkit.getDefaultToolkit(); Dimension screenSize = tk.getScreenSize(); jFrame.setLocation((screenSize.width - jFrame.getSize().width) / 2, (screenSize.height - jFrame.getSize().height) / 2); }
From source file:Main.java
public static void centerFrameOnScreen(JFrame frame) { Toolkit toolkit = Toolkit.getDefaultToolkit(); Dimension screenSize = toolkit.getScreenSize(); Dimension frameSize = frame.getSize(); if (frameSize.height > screenSize.height) { frameSize.height = screenSize.height; }/*from w ww.j av a2s . c o m*/ if (frameSize.width > screenSize.width) { frameSize.width = screenSize.width; } Point p = new Point((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); frame.setLocation(p); }
From source file:com.ethercamp.harmony.desktop.HarmonyDesktop.java
private static void moveCenter(JFrame frame) { Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation(dim.width / 2 - frame.getSize().width / 2, dim.height / 2 - frame.getSize().height / 2); }
From source file:it.unibas.spicygui.controllo.provider.MyPopupSceneMatcher.java
public void creaSliderIniziale() { LayerWidget constraLayerWidget = myGraphScene.getConstraintsLayer(); if (checkSliderShow(constraLayerWidget) == null) { JFrame frame = (JFrame) WindowManager.getDefault().getMainWindow(); int x = (frame.getSize().width / 2) - 20; int y = (int) (frame.getSize().height * 0.5); Point point = SwingUtilities.convertPoint(frame, x, y, myGraphScene); showSliderImpl(constraLayerWidget, point); }/*from w w w. j a v a 2s . c om*/ }
From source file:it.unibas.spicygui.controllo.datasource.operators.CreaWidgetCorrespondencesTGD.java
private Point calculateRandomPoint(GraphSceneGlassPane glassPane) { JFrame frame = (JFrame) WindowManager.getDefault().getMainWindow(); int x = (frame.getSize().width / 2) - 20; int y = random.nextInt((int) (frame.getSize().height * 0.5)) + (int) (frame.getSize().height * 0.2); Point point = SwingUtilities.convertPoint(frame, x, y, glassPane); return point; }
From source file:au.org.ala.delta.util.Utils.java
public static void centreWindow(Window c, JFrame frame) { Dimension app = frame.getSize(); int x = frame.getX() + (app.width - c.getWidth()) / 2; int y = frame.getY() + (app.height - c.getHeight()) / 3; if (y < frame.getY()) { y = frame.getY();/*from ww w . j av a 2 s . c o m*/ } c.setLocation(x, y); }