private static GraphicsDevice getScreen(JFrame window) { for (GraphicsDevice gd : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) { if (gd.getDefaultConfiguration().getBounds().contains(window.getLocationOnScreen())) return gd; } System.err.println( window + " does not appear to be on any screen; fullscreening onto default screen"); return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); }