Refine search
public static Rectangle[] getScreenBounds() { GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); final GraphicsDevice[] screenDevices = graphicsEnvironment.getScreenDevices(); Rectangle[] screenBounds = new Rectangle[screenDevices.length]; for (int i = 0; i < screenDevices.length; i++) { GraphicsDevice screenDevice = screenDevices[i]; final GraphicsConfiguration defaultConfiguration = screenDevice.getDefaultConfiguration(); screenBounds[i] = defaultConfiguration.getBounds(); } return screenBounds; }
/** * Helps client code place components on the center of the screen. It * handles multiple monitor configuration correctly * * @param gconf the GraphicsConfiguration of the monitor * @param componentSize the size of the component * @return bounds of the centered component */ private static Rectangle findCenterBounds(GraphicsConfiguration gconf, Dimension componentSize) { if (gconf == null) { gconf = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration(); } Rectangle bounds = gconf.getBounds(); return new Rectangle( bounds.x + ((bounds.width - componentSize.width) / 2), bounds.y + ((bounds.height - componentSize.height) / 2), componentSize.width, componentSize.height ); }
@Override public void open() { if (open) { return; } LOG.debug("Opening screen device {} with resolution {}", getName(), getResolution()); this.bounds = device .getDefaultConfiguration() .getBounds(); open = true; }
/** * Helps client code place components on the center of the screen. It * handles multiple monitor configuration correctly * * @param gconf the GraphicsConfiguration of the monitor * @param componentSize the size of the component * @return bounds of the centered component */ private static Rectangle findCenterBounds(GraphicsConfiguration gconf, Dimension componentSize) { if (gconf == null) { gconf = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration(); } Rectangle bounds = gconf.getBounds(); return new Rectangle( bounds.x + ((bounds.width - componentSize.width) / 2), bounds.y + ((bounds.height - componentSize.height) / 2), componentSize.width, componentSize.height ); }
for ( GraphicsDevice screen : getGraphicsDevices () ) GraphicsConfiguration gc = screen.getDefaultConfiguration (); Rectangle sb = gc.getBounds ();
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice defaultScreen = ge.getDefaultScreenDevice(); Rectangle rect = defaultScreen.getDefaultConfiguration().getBounds(); int x = (int) rect.getMaxX() - f.getWidth(); int y = (int) rect.getMaxY() - f.getHeight();
Rectangle currentBounds; for (int i = 0; i < nMonitors; i++) { currentBounds = new Rectangle(gdevs[i].getDefaultConfiguration().getBounds()); if (null != allMonitors) { allMonitors = allMonitors.union(currentBounds);
System.out.println(gds[i].getDefaultConfiguration().getBounds()); maxOffsetX = gds[i].getDefaultConfiguration().getBounds().x; maxOffsetY = gds[i].getDefaultConfiguration().getBounds().y;
/** * Get bounds of the screen. * * @return bounds of the screen */ public Rectangle getBounds() { return screen.getDefaultConfiguration().getBounds(); }
public static Rectangle getDeviceBounds(GraphicsDevice device) { GraphicsConfiguration gc = device.getDefaultConfiguration(); Rectangle bounds = gc.getBounds(); return bounds; }
GraphicsDevice device = ge.getDefaultScreenDevice(); // or what ever device you want... GraphicsConfiguration cf = device.getDefaultConfiguration(); Rectangle bounds = cf.getBounds();
/** * If the screen contains specified point. * * @param p point coordinate * @return true if point belongs to screen, false otherwise */ public boolean containsPoint(Point p) { return screen.getDefaultConfiguration().getBounds().contains(p); }
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); // Use this if need to know about a device which is not the default... //GraphicsDevice lstGDs[] = ge.getScreenDevices(); GraphicsDevice device = ge.getDefaultScreenDevice(); GraphicsConfiguration cf = device.getDefaultConfiguration(); Rectangle bounds = cf.getBounds(); Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc); bounds.x += insets.left; bounds.y += insets.top; bounds.width -= (insets.left + insets.right); bounds.height -= (insets.top + insets.bottom);
/** * Returns the bounds of the main monitor device. */ public static Rectangle mainBounds () { GraphicsEnvironment ge = GraphicsEnvironment. getLocalGraphicsEnvironment(); GraphicsDevice dev = ge.getDefaultScreenDevice(); GraphicsConfiguration conf = dev.getDefaultConfiguration (); return conf.getBounds (); } }
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); Rectangle bounds = new Rectangle(0, 0, 0, 0); if (gd != null) { GraphicsConfiguration gc = gd.getDefaultConfiguration(); bounds = gc.getBounds(); Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc); bounds.x += insets.left; bounds.y += insets.top; bounds.width -= (insets.left + insets.right); bounds.height -= (insets.top + insets.bottom); }
private static Rectangle getDefaultScreenBounds() { return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().getBounds(); } }
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gd.getDefaultConfiguration(); Rectangle bounds = gc.getBounds(); JFrame gui = new JFrame("Changeable Resolution"); gui.setSize(bounds.width, bounds.height); gui.setLocation(bounds.x, bounds.y); gui.setDefaultCloseOperation(gui.EXIT_ON_CLOSE); gui.setVisible(true);
private static Rectangle[] getScreens() { GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment(); List<Rectangle> screensList = new ArrayList<Rectangle>(); GraphicsDevice[] screenDevices = environment.getScreenDevices(); for (GraphicsDevice device : screenDevices) { GraphicsConfiguration configuration = device.getDefaultConfiguration(); Rectangle screenBounds = configuration.getBounds(); screensList.add(screenBounds); } return screensList.toArray(new Rectangle[screensList.size()]); }
public static BufferedImage createDesktopScreenshot(GraphicsDevice screen) { GraphicsConfiguration gc = screen.getDefaultConfiguration(); Rectangle rect = gc.getBounds(); return createDesktopScreenshot(screen, rect.x, rect.y, rect.width, rect.height); }
public static Rectangle getScreenBoundsAt(Point pos) { GraphicsDevice gd = getGraphicsDeviceAt(pos); Rectangle bounds = null; if (gd != null) { bounds = gd.getDefaultConfiguration() .getBounds(); } return bounds; }