List of usage examples for java.awt Toolkit getDefaultToolkit
public static synchronized Toolkit getDefaultToolkit()
From source file:Main.java
/** * //from w w w.ja va 2s . c o m * @return The middle point on the screen, for the window */ public static Point getCenterPoint(Window window) { // Get the size of the screen Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); // Determine the new location of the window int w = window.getSize().width; int h = window.getSize().height; int x = (dim.width - w) / 2; int y = (dim.height - h) / 2; return new Point(x, y); }
From source file:Main.java
public static void pack(Component c) { Window window = getFrame(c);/*from w w w . j a va 2s. co m*/ window.pack(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension bounds = new Dimension(); bounds.width = Math.min(window.getWidth(), screenSize.width * 8 / 10); bounds.height = Math.min(window.getHeight(), screenSize.height * 8 / 10); window.setSize(bounds); }
From source file:Main.java
/** * * @param filename nom de l'image.//w w w. j a v a 2 s. c o m * @return l'image. */ public static ImageIcon lireImageIcon(final String filename) { URL url = Main.class.getResource("images/" + filename); return new ImageIcon(Toolkit.getDefaultToolkit().getImage(url)); }
From source file:Main.java
/** * This method centers the given dialog. * * @param dDialog The dialog to center. *///from w ww . ja va 2 s . c om public static void centerDialog(JDialog dDialog) { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension labelSize = dDialog.getSize(); dDialog.setLocation((screenSize.width / 2) - (labelSize.width / 2), (screenSize.height / 2) - (labelSize.height / 2)); }
From source file:Main.java
public static void showDialog(JDialog d) { final Toolkit toolkit = Toolkit.getDefaultToolkit(); final Dimension screenSize = toolkit.getScreenSize(); final int x = (screenSize.width - d.getWidth()) / 2; final int y = (screenSize.height - d.getHeight()) / 2; d.setLocation(x, y);/*from w ww.j av a 2 s. co m*/ d.setVisible(true); }
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. * /*from w w w .j a v a2s .c om*/ * @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 Cursor buildCursorByTrimming(Image image, int x, int y, String name, Cursor defaultCursor) { return buildCursorByTrimming(Toolkit.getDefaultToolkit(), image, x, y, name, defaultCursor); }
From source file:Main.java
public static Image getImage(String name) { if (name == null || name.isEmpty()) { return null; }/* w ww .j a v a 2s .c o m*/ URL imageURL = Main.class.getResource(name); if (imageURL == null) { return null; } return Toolkit.getDefaultToolkit().createImage(imageURL); }
From source file:UIUtilities.java
public static void setFrameLocationRelativeTo(JFrame f, Component c) { if (c == null) { // Setting the position of the dialog on the center of the screen // in 1.4 should be replaced by // f.setLocationRelativeTo(null); Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); f.setLocation((int) d.getWidth() / 2 - (int) f.getPreferredSize().getWidth() / 2, (int) d.getHeight() / 2 - (int) f.getPreferredSize().getHeight() / 2); }//from ww w.jav a 2 s.c o m }
From source file:Main.java
public static int getScreenWidth() { Dimension screenSz = Toolkit.getDefaultToolkit().getScreenSize(); return screenSz.width; }