List of usage examples for java.awt GraphicsEnvironment getScreenDevices
public abstract GraphicsDevice[] getScreenDevices() throws HeadlessException;
From source file:Main.java
/** * @param bounds/* w w w . j a va 2s . co m*/ * @return */ public static GraphicsDevice getScreenByBounds(Rectangle bounds) { final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); final GraphicsDevice[] screens = ge.getScreenDevices(); Rectangle biggestIntersection = null; GraphicsDevice bestScreen = null; for (final GraphicsDevice screen : screens) { final Rectangle sb = screen.getDefaultConfiguration().getBounds(); Rectangle intersection = sb.intersection(bounds); if (intersection != null) { if (biggestIntersection == null || intersection.width * intersection.height > biggestIntersection.width * biggestIntersection.height) { biggestIntersection = intersection; bestScreen = screen; if (intersection.equals(bounds)) { // it will not get better break; } } } } return (biggestIntersection == null || biggestIntersection.width * biggestIntersection.height == 0) ? null : bestScreen; }
From source file:Main.java
/** * @param r/*from w w w . ja v a 2 s . c om*/ * the original rectangle * @param includeReservedInsets * if taskbar and other windowing insets should be included in the * returned area * @return iff there are multiple monitors the other monitor than the * effective view of the monitor that the rectangle mostly coveres, or * null if there is just one screen */ public static Rectangle getOppositeFullScreenBoundsFor(Rectangle r, boolean includeReservedInsets) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); TreeMap<Integer, Rectangle> prioMap = new TreeMap<Integer, Rectangle>(); for (GraphicsDevice dev : ge.getScreenDevices()) { Rectangle bounds; if ((!includeReservedInsets) && dev == ge.getDefaultScreenDevice()) { bounds = ge.getMaximumWindowBounds(); } else { bounds = dev.getDefaultConfiguration().getBounds(); } Rectangle intersection = bounds.intersection(r); prioMap.put(intersection.width * intersection.height, bounds); } if (prioMap.size() <= 1) { return null; } else { return prioMap.get(prioMap.firstKey()); } }
From source file:com.seleniumtests.driver.CustomEventFiringWebDriver.java
/** * Returns the rectangle of all screens on the system * @return/*from ww w .ja v a 2s . co m*/ */ private static Rectangle getScreensRectangle() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); Rectangle screenRect = new Rectangle(0, 0, 0, 0); for (GraphicsDevice gd : ge.getScreenDevices()) { screenRect = screenRect.union(gd.getDefaultConfiguration().getBounds()); } return screenRect; }
From source file:Main.java
void initUI() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); int i = 1;//w w w . jav a2 s . c o m for (GraphicsDevice gd : ge.getScreenDevices()) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(createLabel(String.valueOf(i))); frame.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "exit"); frame.getRootPane().getActionMap().put("exit", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { System.exit(0); } }); frame.setLocation(gd.getDefaultConfiguration().getBounds().getLocation()); frame.setUndecorated(true); frame.setExtendedState(frame.getExtendedState() | JFrame.MAXIMIZED_BOTH); frame.setVisible(true); gd.setFullScreenWindow(frame); i++; } }
From source file:com._17od.upm.gui.MainWindow.java
/** * Convenience method to iterate over all graphics configurations. *//*from w w w .j a v a2 s . c o m*/ private static ArrayList getConfigs() { ArrayList result = new ArrayList(); GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] devices = env.getScreenDevices(); for (int i = 0; i < devices.length; i++) { GraphicsConfiguration[] configs = devices[i].getConfigurations(); result.addAll(Arrays.asList(configs)); } return result; }
From source file:com.tag.FramePreferences.java
public final Rectangle getGraphicsBounds() { GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment(); Rectangle r = null;/* www.j av a 2s . c o m*/ for (GraphicsDevice device : environment.getScreenDevices()) { GraphicsConfiguration config = device.getDefaultConfiguration(); if (r == null) { r = config.getBounds(); } else { r.add(config.getBounds()); } } return r; }
From source file:es.mityc.firmaJava.libreria.pkcs7.ValidaTarjeta.java
/** * This method initializes this/* w w w . j a v a2s .c o m*/ * */ private void initialize() { this.setSize(new Dimension(534, 264)); this.setResizable(false); this.setModal(true); this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.setContentPane(getJPanel()); this.setTitle(I18n.getResource(LIBRERIAXADES_VALIDARTARJETA_TEXTO_5)); // Centramos la ventana del applet // Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); int screenWidth = 0; int screenHeight = 0; int longitud = gs.length; for (int i = 0; i < longitud; i++) { DisplayMode dm = gs[i].getDisplayMode(); screenWidth = dm.getWidth(); screenHeight = dm.getHeight(); } this.setLocation((int) (screenWidth / 2) - (int) (539 / 2), (int) (screenHeight / 2) - (int) (497 / 2)); }
From source file:com._17od.upm.gui.MainWindow.java
/** * Utility function for restoreWindowBounds *//* www . j av a 2 s .c o m*/ private GraphicsConfiguration getGraphicsConfigurationContaining(int x, int y) { ArrayList configs = new ArrayList(); GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] devices = env.getScreenDevices(); for (int i = 0; i < devices.length; i++) { GraphicsConfiguration[] gconfigs = devices[i].getConfigurations(); configs.addAll(Arrays.asList(gconfigs)); } for (int i = 0; i < configs.size(); i++) { GraphicsConfiguration config = ((GraphicsConfiguration) configs.get(i)); Rectangle bounds = config.getBounds(); if (bounds.contains(x, y)) { return config; } } return null; }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java
public void checkForInitialLoadScreenSizes(final FormControl control, final JSplitPane verticalMain, final String verticalMainName, final JSplitPane verticalSub, final String verticalSubName, final JSplitPane horizontalMain, final String horizontalMainName, final JSplitPane horizontalSub, final String horizontalSubName) { if ((control.getWidth() == -1) && (control.getHeight() == -1) && (control.getLeft() == -1) && (control.getTop() == -1)) { final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); final GraphicsDevice[] gs = ge.getScreenDevices(); if (gs.length > 0) { final DisplayMode dm = gs[0].getDisplayMode(); final int screenWidth = dm.getWidth() - 20; final int screenHeight = dm.getHeight() - 50; // Set form bounds control.setTop(10);/*from w ww .ja v a2s .c om*/ control.setLeft(10); control.setWidth(screenWidth); control.setHeight(screenHeight); control.resizeScreen(); // Set divider positions int dividerPosition = 175; verticalMain.setDividerLocation(dividerPosition); control.setExtra(verticalMainName, dividerPosition); dividerPosition = screenHeight / 3; verticalSub.setDividerLocation(dividerPosition); control.setExtra(verticalSubName, dividerPosition); dividerPosition = screenWidth / 3; horizontalMain.setDividerLocation(dividerPosition); control.setExtra(horizontalMainName, dividerPosition); horizontalSub.setDividerLocation(dividerPosition); control.setExtra(horizontalSubName, dividerPosition); } } }