List of usage examples for java.awt Toolkit getDefaultToolkit
public static synchronized Toolkit getDefaultToolkit()
From source file:Main.java
public static void window_centered(JFrame frame) { frame.pack();/*from ww w . ja v a2s. co m*/ Toolkit kit = Toolkit.getDefaultToolkit(); Dimension screenSize = kit.getScreenSize(); int width = screenSize.width; int height = screenSize.height; int x = (width - frame.getWidth()) / 2; int y = (height - frame.getHeight()) / 2; frame.setLocation(x, y); }
From source file:Main.java
public static void setFullScreen(JFrame component) { Dimension size = Toolkit.getDefaultToolkit().getScreenSize(); component.setSize(size); }
From source file:Main.java
public static void center(JFrame mainWindow) { Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); int x = (int) ((dimension.getWidth() - mainWindow.getWidth()) / 2); int y = (int) ((dimension.getHeight() - mainWindow.getHeight()) / 2); mainWindow.setLocation(x, y);/*from ww w . ja va2 s .c o m*/ }
From source file:Main.java
public static void center(Window window) { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = window.getSize(); frameSize.height = ((frameSize.height > screenSize.height) ? screenSize.height : frameSize.height); frameSize.width = ((frameSize.width > screenSize.width) ? screenSize.width : frameSize.width); window.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); }
From source file:Main.java
public static void center(Component component) { Toolkit toolkit = Toolkit.getDefaultToolkit(); Dimension screenSize = toolkit.getScreenSize(); int x = (screenSize.width - component.getWidth()) / 2; int y = (screenSize.height - component.getHeight()) / 2; component.setLocation(x, y);//from www.j av a2s . c o m }
From source file:Main.java
public static void centerJFrame(JFrame jFrame) { Toolkit toolkit = Toolkit.getDefaultToolkit(); Dimension screenSize = toolkit.getScreenSize(); int x = (screenSize.width - jFrame.getWidth()) / 2; int y = (screenSize.height - jFrame.getHeight()) / 2; jFrame.setLocation(x, y);//from ww w .j a v a 2 s. co m }
From source file:Main.java
public static void setMaximized(JFrame frame) { Dimension screenSz = Toolkit.getDefaultToolkit().getScreenSize(); frame.setBounds(0, 0, screenSz.width, screenSz.height); }
From source file:Main.java
public static void centerOnScreen(Window window) { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension size = window.getSize(); window.setLocation((screenSize.width - size.width) / 2, (screenSize.height - size.height) / 2); }
From source file:Main.java
public static Dimension currentWindowSize(double widthRatio, double heightRatio) { Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); Dimension rtnDim = new Dimension(); rtnDim.width = new Double(dim.getWidth() * widthRatio).intValue(); rtnDim.height = new Double(dim.getHeight() * heightRatio).intValue(); return rtnDim; }
From source file:Main.java
public static void centerContainer(Window window) { Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); Dimension size = window.getSize(); int newWidth = (screen.width - size.width) / 2; int newHeight = (screen.height - size.height) / 2; window.setLocation(newWidth, newHeight); }