device.getConfigurations(); for (GraphicsConfiguration config: configurations) { Rectangle bounds = config.getBounds();
gd.getIDstring())); GraphicsConfiguration[] gc = gd.getConfigurations(); for (int i = 0; i < gc.length; i++) { sb.append(
Rectangle2D result = new Rectangle2D.Double(); GraphicsEnvironment localGE = GraphicsEnvironment.getLocalGraphicsEnvironment(); for (GraphicsDevice gd : localGE.getScreenDevices()) { for (GraphicsConfiguration graphicsConfiguration : gd.getConfigurations()) { result.union(result, graphicsConfiguration.getBounds(), result); } } f.setSize(result.getWidth(), result.getHeight());
/** * Returns the screen coordinates for the monitor that contains the * specified point. This is useful for setups with multiple monitors, * to ensure that popup windows are positioned properly. * * @param x The x-coordinate, in screen coordinates. * @param y The y-coordinate, in screen coordinates. * @return The bounds of the monitor that contains the specified point. */ public static Rectangle getScreenBoundsForPoint(int x, int y) { GraphicsEnvironment env = GraphicsEnvironment. getLocalGraphicsEnvironment(); GraphicsDevice[] devices = env.getScreenDevices(); for (int i=0; i<devices.length; i++) { GraphicsConfiguration[] configs = devices[i].getConfigurations(); for (int j=0; j<configs.length; j++) { Rectangle gcBounds = configs[j].getBounds(); if (gcBounds.contains(x, y)) { return gcBounds; } } } // If point is outside all monitors, default to default monitor (?) return env.getMaximumWindowBounds(); }
int numberOfMonitors = 0; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); for (int j = 0; j < gs.length; j++) { GraphicsDevice gd = gs[j]; GraphicsConfiguration[] gc = gd.getConfigurations(); if (gc.getType() == TYPE_RASTER_SCREEN) numberOfMonitors++; } System.out.println("Number of monitors: " + numberOfMonitors);
import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; public class GuiScreens { public static void main(String[] args) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); GraphicsConfiguration[] gc = gs[0].getConfigurations(); System.out.println(" Bounds: " + gc[0].getBounds()); } }
public static Rectangle getPrimaryMonitorScreenRect() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gds = ge.getScreenDevices(); return gds[0].getConfigurations()[0].getBounds(); }
public static Rectangle getPrimaryMonitorScreenRect() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gds = ge.getScreenDevices(); return gds[0].getConfigurations()[0].getBounds(); }
GraphicsEnvironment ge=GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gs=ge.getScreenDevices(); for(int j = 0; j<gs.length; j++) { GraphicsDevice gd=gs[j]; GraphicsConfiguration[] gc=gd.getConfigurations(); for (int i=0; i<gc.length; i++) { ... } }
private static Dimension getScreenSize() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gd = ge.getScreenDevices(); GraphicsConfiguration[] gc = gd[0].getConfigurations(); Rectangle bounds = gc[0].getBounds(); if ((bounds.x==0&&bounds.y==0) || (IJ.isLinux()&&gc.length>1)) return new Dimension(bounds.width, bounds.height); else return Toolkit.getDefaultToolkit().getScreenSize(); }
private static Dimension getScreenSize() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gd = ge.getScreenDevices(); GraphicsConfiguration[] gc = gd[0].getConfigurations(); Rectangle bounds = gc[0].getBounds(); if ((bounds.x==0&&bounds.y==0) || (IJ.isLinux()&&gc.length>1)) return new Dimension(bounds.width, bounds.height); else return Toolkit.getDefaultToolkit().getScreenSize(); }
public class ScreenTest { public static void main(String[] args) { GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment(); for(GraphicsDevice device : environment.getScreenDevices()) { System.out.println(device.getIDstring()); for(GraphicsConfiguration configuration : device.getConfigurations()) { System.out.println(configuration.getBounds()); } System.out.println(); } } }
/** Get the bounds rectangle for all displays. */ static Rectangle getDisplaySpan() { Rectangle bounds = new Rectangle(); GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment(); for (GraphicsDevice device : environment.getScreenDevices()) { for (GraphicsConfiguration config : device.getConfigurations()) { Rectangle2D.union(bounds, config.getBounds(), bounds); } } return bounds; }
public static Rectangle getVirtualScreenBounds() { Rectangle virtualBounds = new Rectangle(); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); for (GraphicsDevice gd : gs) { GraphicsConfiguration[] gc = gd.getConfigurations(); for (GraphicsConfiguration aGc : gc) { virtualBounds = virtualBounds.union(aGc.getBounds()); } } return virtualBounds; }
private static Rectangle configurarMaximizar(){ GraphicsDevice monitorAtual = MouseInfo.getPointerInfo().getDevice(); Rectangle bounds = monitorAtual.getDefaultConfiguration().getBounds(); GraphicsConfiguration gcc[] = monitorAtual.getConfigurations(); Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(gcc[0]); Rectangle newBounds = new Rectangle(bounds.width - (screenInsets.left + screenInsets.right), bounds.height - (screenInsets.top + screenInsets.bottom)); newBounds.x = monitorAtual.getDefaultConfiguration().getBounds().x + screenInsets.left; newBounds.y = monitorAtual.getDefaultConfiguration().getBounds().y + screenInsets.top; return newBounds; }
/** * Calculate the entire virtual desktop bounding rectangle */ private static Rectangle getVirtualDesktopBounds() { Rectangle virtualBounds = new Rectangle(); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); for (GraphicsDevice gd : ge.getScreenDevices()) { for (GraphicsConfiguration gc : gd.getConfigurations()) { virtualBounds = virtualBounds.union(gc.getBounds()); } } return virtualBounds; }
private static GraphicsConfiguration findGraphicsConfiguration(final Component component, int x, int y) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); for (int j = 0; j < gs.length; j++) { GraphicsDevice gd = gs[j]; GraphicsConfiguration[] gc = gd.getConfigurations(); for (int i=0; i < gc.length; i++) { final Rectangle screenBounds = gc[i].getBounds(); if(screenBounds.contains(x, y)) return gc[i]; } } return component != null ? component.getGraphicsConfiguration() : null; }
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); for(GraphicsDevice curGs : gs) { GraphicsConfiguration[] gc = curGs.getConfigurations(); for(GraphicsConfiguration curGc : gc) { Rectangle bounds = curGc.getBounds(); System.out.println(bounds.getX() + "," + bounds.getY() + " " + bounds.getWidth() + "x" + bounds.getHeight()); } }
/** Return whether the given {@link Point} is visible on any screen. */ public static boolean onScreen(Point p) { GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gs = env.getScreenDevices(); for (int i=0;i < gs.length;i++) { GraphicsConfiguration[] gc = gs[i].getConfigurations(); for (int j=0;j < gc.length;j++) { Rectangle r = getVisibleBounds(gc[j]); if (r.contains(p)) return true; } } return false; }
Rectangle virtualBounds = new Rectangle(); GraphicsEnvironment ge = GraphicsEnvironment. getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); for (int j = 0; j < gs.length; j++) { GraphicsDevice gd = gs[j]; GraphicsConfiguration[] gc = gd.getConfigurations(); for (int i=0; i < gc.length; i++) { virtualBounds = virtualBounds.union(gc[i].getBounds()); } }