/** Returns the size, in pixels, of the primary display. */ public static Dimension getScreenSize() { Rectangle bounds = GUI.getZeroBasedMaxBounds(); if (bounds!=null) return new Dimension(bounds.width, bounds.height); if (isWindows()) // GraphicsEnvironment.getConfigurations is *very* slow on Windows return Toolkit.getDefaultToolkit().getScreenSize(); if (GraphicsEnvironment.isHeadless()) return new Dimension(0, 0); // Can't use Toolkit.getScreenSize() on Linux because it returns // size of all displays rather than just the primary display. GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gd = ge.getScreenDevices(); GraphicsConfiguration[] gc = gd[0].getConfigurations(); 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(); }
/** Returns the size, in pixels, of the primary display. */ public static Dimension getScreenSize() { Rectangle bounds = GUI.getZeroBasedMaxBounds(); if (bounds!=null) return new Dimension(bounds.width, bounds.height); if (isWindows()) // GraphicsEnvironment.getConfigurations is *very* slow on Windows return Toolkit.getDefaultToolkit().getScreenSize(); if (GraphicsEnvironment.isHeadless()) return new Dimension(0, 0); // Can't use Toolkit.getScreenSize() on Linux because it returns // size of all displays rather than just the primary display. GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gd = ge.getScreenDevices(); GraphicsConfiguration[] gc = gd[0].getConfigurations(); 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(); }