Java Code Examples for java.awt.GraphicsEnvironment#getScreenDevices()
The following examples show how to use
java.awt.GraphicsEnvironment#getScreenDevices() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CheckDisplayModes.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); for (GraphicsDevice graphicDevice : ge.getScreenDevices()) { if (!graphicDevice.isDisplayChangeSupported()) { System.err.println("Display mode change is not supported on this host. Test is considered passed."); continue; } DisplayMode defaultDisplayMode = graphicDevice.getDisplayMode(); checkDisplayMode(defaultDisplayMode); graphicDevice.setDisplayMode(defaultDisplayMode); DisplayMode[] displayModes = graphicDevice.getDisplayModes(); boolean isDefaultDisplayModeIncluded = false; for (DisplayMode displayMode : displayModes) { checkDisplayMode(displayMode); graphicDevice.setDisplayMode(displayMode); if (defaultDisplayMode.equals(displayMode)) { isDefaultDisplayModeIncluded = true; } } if (!isDefaultDisplayModeIncluded) { throw new RuntimeException("Default display mode is not included"); } } }
Example 2
Source File: JComboBoxPopupLocation.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(final String[] args) throws Exception { robot = new Robot(); robot.setAutoDelay(100); robot.setAutoWaitForIdle(true); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] sds = ge.getScreenDevices(); UIManager.LookAndFeelInfo[] lookAndFeelArray = UIManager.getInstalledLookAndFeels(); for (UIManager.LookAndFeelInfo lookAndFeelItem : lookAndFeelArray) { System.setProperty(PROPERTY_NAME, "true"); step(sds, lookAndFeelItem); if (lookAndFeelItem.getClassName().contains("Aqua")) { System.setProperty(PROPERTY_NAME, "false"); step(sds, lookAndFeelItem); } } }
Example 3
Source File: CheckDisplayModes.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); for (GraphicsDevice graphicDevice : ge.getScreenDevices()) { if (!graphicDevice.isDisplayChangeSupported()) { System.err.println("Display mode change is not supported on this host. Test is considered passed."); continue; } DisplayMode defaultDisplayMode = graphicDevice.getDisplayMode(); checkDisplayMode(defaultDisplayMode); graphicDevice.setDisplayMode(defaultDisplayMode); DisplayMode[] displayModes = graphicDevice.getDisplayModes(); boolean isDefaultDisplayModeIncluded = false; for (DisplayMode displayMode : displayModes) { checkDisplayMode(displayMode); graphicDevice.setDisplayMode(displayMode); if (defaultDisplayMode.equals(displayMode)) { isDefaultDisplayModeIncluded = true; } } if (!isDefaultDisplayModeIncluded) { throw new RuntimeException("Default display mode is not included"); } } }
Example 4
Source File: bug7072653.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { robot = new Robot(); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); UIManager.LookAndFeelInfo[] lookAndFeelArray = UIManager.getInstalledLookAndFeels(); for (GraphicsDevice sd : ge.getScreenDevices()) { for (UIManager.LookAndFeelInfo lookAndFeelItem : lookAndFeelArray) { executeCase(lookAndFeelItem.getClassName(), sd); robot.waitForIdle(); } } }
Example 5
Source File: GameWindow.java From open-ig with GNU Lesser General Public License v3.0 | 5 votes |
/** * Toggle between full screen mode. */ void switchFullscreen() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); for (final GraphicsDevice gs : ge.getScreenDevices()) { if (gs.getDefaultConfiguration().getBounds().intersects(getBounds())) { GameWindow gw = new GameWindow(GameWindow.this, gs.getFullScreenWindow() == null); if (gs.getFullScreenWindow() == null) { gw.saveX = getX(); gw.saveY = getY(); gw.saveWidth = getWidth(); gw.saveHeight = getHeight(); done(); dispose(); gs.setFullScreenWindow(gw); // Mac workaround for not having the keyboard focus in fullscreen. gw.setVisible(false); gw.setVisible(true); setSize(gs.getDefaultConfiguration().getBounds().getSize()); } else { done(); dispose(); gs.setFullScreenWindow(null); gw.setBounds(saveX, saveY, saveWidth, saveHeight); gw.setVisible(true); } gw.requestFocus(); gw.moveMouse(); break; } } }
Example 6
Source File: HeadUI.java From Forsythia with GNU General Public License v3.0 | 5 votes |
private void enterFullScreenMode(){ fullscreenmode=true; GraphicsEnvironment env = GraphicsEnvironment. getLocalGraphicsEnvironment(); GraphicsDevice[] devices = env.getScreenDevices(); device=devices[0]; originaldm = device.getDisplayMode(); boolean isfullscreenable = device.isFullScreenSupported(); //get rid of the frame decor setVisible(false); dispose(); setUndecorated(isfullscreenable); setVisible(true); // setResizable(!isfullscreenable); //hide controls pancontrol.setVisible(false); //get the focus on the image panel so we can exit on keypress panimage.requestFocus(); //do fullscreen if(isfullscreenable){ device.setFullScreenWindow(this); pancontrol.setVisible(false); //can't do fullscreen so do this other thing }else{ setVisible(true);} validate(); hideMouse();}
Example 7
Source File: GlobalUtils.java From aurous-app with GNU General Public License v2.0 | 5 votes |
/** * Center a frame on the main display * * @param frame * The frame to center */ public void centerFrameOnMainDisplay(final JFrame frame) { final GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); final GraphicsDevice[] screens = ge.getScreenDevices(); if (screens.length < 1) { return; // Silently fail. } final Rectangle screenBounds = screens[0].getDefaultConfiguration() .getBounds(); final int x = (int) ((screenBounds.getWidth() - frame.getWidth()) / 2); final int y = (int) ((screenBounds.getHeight() - frame.getHeight()) / 2); frame.setLocation(x, y); }
Example 8
Source File: Utils.java From DroidUIBuilder with Apache License 2.0 | 5 votes |
public static void fullScreen(Window w) { GraphicsEnvironment env = GraphicsEnvironment .getLocalGraphicsEnvironment(); for (GraphicsDevice device : env.getScreenDevices()) { if (device.isFullScreenSupported()) { device.setFullScreenWindow(w); return; } } MainPane.getTipCom().warn("No supported device for fullscreen mode."); }
Example 9
Source File: ScaledTransform.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) { GraphicsEnvironment ge = GraphicsEnvironment. getLocalGraphicsEnvironment(); if (ge.isHeadlessInstance()) { return; } for (GraphicsDevice gd : ge.getScreenDevices()) { for (GraphicsConfiguration gc : gd.getConfigurations()) { testScaleFactor(gc); } } }
Example 10
Source File: bug8071705.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
private static GraphicsDevice[] checkScreens() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); return ge.getScreenDevices(); }
Example 11
Source File: ScreenInsetsTest.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { boolean passed = true; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gds = ge.getScreenDevices(); for (GraphicsDevice gd : gds) { GraphicsConfiguration gc = gd.getDefaultConfiguration(); Rectangle gcBounds = gc.getBounds(); Insets gcInsets = Toolkit.getDefaultToolkit().getScreenInsets(gc); int left = gcInsets.left; int right = gcInsets.right; int bottom = gcInsets.bottom; int top = gcInsets.top; if (left < 0 || right < 0 || bottom < 0 || top < 0) { throw new RuntimeException("Negative value: " + gcInsets); } int maxW = gcBounds.width / 3; int maxH = gcBounds.height / 3; if (left > maxW || right > maxW || bottom > maxH || top > maxH) { throw new RuntimeException("Big value: " + gcInsets); } if (!Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH)) { // this state is used in the test - sorry continue; } Frame f = new Frame("Test", gc); f.setUndecorated(true); f.setBounds(gcBounds.x + 100, gcBounds.y + 100, 320, 240); f.setVisible(true); Util.waitForIdle(null); f.setExtendedState(Frame.MAXIMIZED_BOTH); Util.waitForIdle(null); Rectangle fBounds = f.getBounds(); // workaround: on Windows maximized windows have negative coordinates if (fBounds.x < gcBounds.x) { fBounds.width -= (gcBounds.x - fBounds.x) * 2; // width is decreased fBounds.x = gcBounds.x; } if (fBounds.y < gcBounds.y) { fBounds.height -= (gcBounds.y - fBounds.y) * 2; // height is decreased fBounds.y = gcBounds.y; } Insets expected = new Insets(fBounds.y - gcBounds.y, fBounds.x - gcBounds.x, gcBounds.y + gcBounds.height - fBounds.y - fBounds.height, gcBounds.x + gcBounds.width - fBounds.x - fBounds.width); if (!expected.equals(gcInsets)) { passed = false; System.err.println("Wrong insets for GraphicsConfig: " + gc); System.err.println("\tExpected: " + expected); System.err.println("\tActual: " + gcInsets); } f.dispose(); } if (!passed) { throw new RuntimeException("TEST FAILED: Toolkit.getScreenInsets() returns wrong value for some screens"); } }
Example 12
Source File: FullScreenInsets.java From hottub with GNU General Public License v2.0 | 4 votes |
public static void main(final String[] args) { final GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); final GraphicsDevice[] devices = ge.getScreenDevices(); final Window wGreen = new Frame(); wGreen.setBackground(Color.GREEN); wGreen.setSize(300, 300); wGreen.setVisible(true); sleep(); final Insets iGreen = wGreen.getInsets(); final Dimension sGreen = wGreen.getSize(); final Window wRed = new Frame(); wRed.setBackground(Color.RED); wRed.setSize(300, 300); wRed.setVisible(true); sleep(); final Insets iRed = wGreen.getInsets(); final Dimension sRed = wGreen.getSize(); for (final GraphicsDevice device : devices) { if (!device.isFullScreenSupported()) { continue; } device.setFullScreenWindow(wGreen); sleep(); testWindowBounds(device.getDisplayMode(), wGreen); testColor(wGreen, Color.GREEN); device.setFullScreenWindow(wRed); sleep(); testWindowBounds(device.getDisplayMode(), wRed); testColor(wRed, Color.RED); device.setFullScreenWindow(null); sleep(); testInsets(wGreen.getInsets(), iGreen); testInsets(wRed.getInsets(), iRed); testSize(wGreen.getSize(), sGreen); testSize(wRed.getSize(), sRed); } wGreen.dispose(); wRed.dispose(); if (!passed) { throw new RuntimeException("Test failed"); } }
Example 13
Source File: FullScreenInsets.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(final String[] args) { final GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); final GraphicsDevice[] devices = ge.getScreenDevices(); final Window wGreen = new Frame(); wGreen.setBackground(Color.GREEN); wGreen.setSize(300, 300); wGreen.setVisible(true); sleep(); final Insets iGreen = wGreen.getInsets(); final Dimension sGreen = wGreen.getSize(); final Window wRed = new Frame(); wRed.setBackground(Color.RED); wRed.setSize(300, 300); wRed.setVisible(true); sleep(); final Insets iRed = wGreen.getInsets(); final Dimension sRed = wGreen.getSize(); for (final GraphicsDevice device : devices) { if (!device.isFullScreenSupported()) { continue; } device.setFullScreenWindow(wGreen); sleep(); testWindowBounds(device.getDisplayMode(), wGreen); testColor(wGreen, Color.GREEN); device.setFullScreenWindow(wRed); sleep(); testWindowBounds(device.getDisplayMode(), wRed); testColor(wRed, Color.RED); device.setFullScreenWindow(null); sleep(); testInsets(wGreen.getInsets(), iGreen); testInsets(wRed.getInsets(), iRed); testSize(wGreen.getSize(), sGreen); testSize(wRed.getSize(), sRed); } wGreen.dispose(); wRed.dispose(); if (!passed) { throw new RuntimeException("Test failed"); } }
Example 14
Source File: FullScreenInsets.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public static void main(final String[] args) { final GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); final GraphicsDevice[] devices = ge.getScreenDevices(); final Window wGreen = new Frame(); wGreen.setBackground(Color.GREEN); wGreen.setSize(300, 300); wGreen.setVisible(true); sleep(); final Insets iGreen = wGreen.getInsets(); final Dimension sGreen = wGreen.getSize(); final Window wRed = new Frame(); wRed.setBackground(Color.RED); wRed.setSize(300, 300); wRed.setVisible(true); sleep(); final Insets iRed = wGreen.getInsets(); final Dimension sRed = wGreen.getSize(); for (final GraphicsDevice device : devices) { if (!device.isFullScreenSupported()) { continue; } device.setFullScreenWindow(wGreen); sleep(); testWindowBounds(device.getDisplayMode(), wGreen); testColor(wGreen, Color.GREEN); device.setFullScreenWindow(wRed); sleep(); testWindowBounds(device.getDisplayMode(), wRed); testColor(wRed, Color.RED); device.setFullScreenWindow(null); sleep(); testInsets(wGreen.getInsets(), iGreen); testInsets(wRed.getInsets(), iRed); testSize(wGreen.getSize(), sGreen); testSize(wRed.getSize(), sRed); } wGreen.dispose(); wRed.dispose(); if (!passed) { throw new RuntimeException("Test failed"); } }
Example 15
Source File: MultiScreenLocationTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws AWTException { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gds = ge.getScreenDevices(); if (gds.length < 2) { System.out.println("It's a multiscreen test... skipping!"); return; } for (int i = 0; i < gds.length; ++i) { GraphicsDevice gd = gds[i]; GraphicsConfiguration gc = gd.getDefaultConfiguration(); Rectangle screen = gc.getBounds(); Robot robot = new Robot(gd); // check Robot.mouseMove() robot.mouseMove(screen.x + mouseOffset.x, screen.y + mouseOffset.y); Point mouse = MouseInfo.getPointerInfo().getLocation(); Point point = screen.getLocation(); point.translate(mouseOffset.x, mouseOffset.y); if (!point.equals(mouse)) { throw new RuntimeException(getErrorText("Robot.mouseMove", i)); } // check Robot.getPixelColor() Frame frame = new Frame(gc); frame.setUndecorated(true); frame.setSize(100, 100); frame.setLocation(screen.x + frameOffset.x, screen.y + frameOffset.y); frame.setBackground(color); frame.setVisible(true); robot.waitForIdle(); Rectangle bounds = frame.getBounds(); if (!Util.testBoundsColor(bounds, color, 5, 1000, robot)) { throw new RuntimeException(getErrorText("Robot.getPixelColor", i)); } // check Robot.createScreenCapture() BufferedImage image = robot.createScreenCapture(bounds); int rgb = color.getRGB(); if (image.getRGB(0, 0) != rgb || image.getRGB(image.getWidth() - 1, 0) != rgb || image.getRGB(image.getWidth() - 1, image.getHeight() - 1) != rgb || image.getRGB(0, image.getHeight() - 1) != rgb) { throw new RuntimeException( getErrorText("Robot.createScreenCapture", i)); } frame.dispose(); } System.out.println("Test PASSED!"); }
Example 16
Source File: ScreenInsetsTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { boolean passed = true; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gds = ge.getScreenDevices(); for (GraphicsDevice gd : gds) { GraphicsConfiguration gc = gd.getDefaultConfiguration(); Rectangle gcBounds = gc.getBounds(); Insets gcInsets = Toolkit.getDefaultToolkit().getScreenInsets(gc); int left = gcInsets.left; int right = gcInsets.right; int bottom = gcInsets.bottom; int top = gcInsets.top; if (left < 0 || right < 0 || bottom < 0 || top < 0) { throw new RuntimeException("Negative value: " + gcInsets); } int maxW = gcBounds.width / 3; int maxH = gcBounds.height / 3; if (left > maxW || right > maxW || bottom > maxH || top > maxH) { throw new RuntimeException("Big value: " + gcInsets); } if (!Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH)) { // this state is used in the test - sorry continue; } Frame f = new Frame("Test", gc); f.setUndecorated(true); f.setBounds(gcBounds.x + 100, gcBounds.y + 100, 320, 240); f.setVisible(true); Util.waitForIdle(null); f.setExtendedState(Frame.MAXIMIZED_BOTH); Util.waitForIdle(null); Rectangle fBounds = f.getBounds(); // workaround: on Windows maximized windows have negative coordinates if (fBounds.x < gcBounds.x) { fBounds.width -= (gcBounds.x - fBounds.x) * 2; // width is decreased fBounds.x = gcBounds.x; } if (fBounds.y < gcBounds.y) { fBounds.height -= (gcBounds.y - fBounds.y) * 2; // height is decreased fBounds.y = gcBounds.y; } Insets expected = new Insets(fBounds.y - gcBounds.y, fBounds.x - gcBounds.x, gcBounds.y + gcBounds.height - fBounds.y - fBounds.height, gcBounds.x + gcBounds.width - fBounds.x - fBounds.width); if (!expected.equals(gcInsets)) { passed = false; System.err.println("Wrong insets for GraphicsConfig: " + gc); System.err.println("\tExpected: " + expected); System.err.println("\tActual: " + gcInsets); } f.dispose(); } if (!passed) { throw new RuntimeException("TEST FAILED: Toolkit.getScreenInsets() returns wrong value for some screens"); } }
Example 17
Source File: bug8071705.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
private static GraphicsDevice[] checkScreens() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); return ge.getScreenDevices(); }
Example 18
Source File: bug8071705.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
private static GraphicsDevice[] checkScreens() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); return ge.getScreenDevices(); }
Example 19
Source File: FullScreenInsets.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(final String[] args) { final GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); final GraphicsDevice[] devices = ge.getScreenDevices(); final Window wGreen = new Frame(); wGreen.setBackground(Color.GREEN); wGreen.setSize(300, 300); wGreen.setVisible(true); sleep(); final Insets iGreen = wGreen.getInsets(); final Dimension sGreen = wGreen.getSize(); final Window wRed = new Frame(); wRed.setBackground(Color.RED); wRed.setSize(300, 300); wRed.setVisible(true); sleep(); final Insets iRed = wGreen.getInsets(); final Dimension sRed = wGreen.getSize(); for (final GraphicsDevice device : devices) { if (!device.isFullScreenSupported()) { continue; } device.setFullScreenWindow(wGreen); sleep(); testWindowBounds(device.getDisplayMode(), wGreen); testColor(wGreen, Color.GREEN); device.setFullScreenWindow(wRed); sleep(); testWindowBounds(device.getDisplayMode(), wRed); testColor(wRed, Color.RED); device.setFullScreenWindow(null); sleep(); testInsets(wGreen.getInsets(), iGreen); testInsets(wRed.getInsets(), iRed); testSize(wGreen.getSize(), sGreen); testSize(wRed.getSize(), sRed); } wGreen.dispose(); wRed.dispose(); if (!passed) { throw new RuntimeException("Test failed"); } }
Example 20
Source File: ScreenInsetsTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { boolean passed = true; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gds = ge.getScreenDevices(); for (GraphicsDevice gd : gds) { GraphicsConfiguration gc = gd.getDefaultConfiguration(); Rectangle gcBounds = gc.getBounds(); Insets gcInsets = Toolkit.getDefaultToolkit().getScreenInsets(gc); int left = gcInsets.left; int right = gcInsets.right; int bottom = gcInsets.bottom; int top = gcInsets.top; if (left < 0 || right < 0 || bottom < 0 || top < 0) { throw new RuntimeException("Negative value: " + gcInsets); } int maxW = gcBounds.width / 3; int maxH = gcBounds.height / 3; if (left > maxW || right > maxW || bottom > maxH || top > maxH) { throw new RuntimeException("Big value: " + gcInsets); } if (!Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH)) { // this state is used in the test - sorry continue; } Frame f = new Frame("Test", gc); f.setUndecorated(true); f.setBounds(gcBounds.x + 100, gcBounds.y + 100, 320, 240); f.setVisible(true); Util.waitForIdle(null); f.setExtendedState(Frame.MAXIMIZED_BOTH); Util.waitForIdle(null); Rectangle fBounds = f.getBounds(); // workaround: on Windows maximized windows have negative coordinates if (fBounds.x < gcBounds.x) { fBounds.width -= (gcBounds.x - fBounds.x) * 2; // width is decreased fBounds.x = gcBounds.x; } if (fBounds.y < gcBounds.y) { fBounds.height -= (gcBounds.y - fBounds.y) * 2; // height is decreased fBounds.y = gcBounds.y; } Insets expected = new Insets(fBounds.y - gcBounds.y, fBounds.x - gcBounds.x, gcBounds.y + gcBounds.height - fBounds.y - fBounds.height, gcBounds.x + gcBounds.width - fBounds.x - fBounds.width); if (!expected.equals(gcInsets)) { passed = false; System.err.println("Wrong insets for GraphicsConfig: " + gc); System.err.println("\tExpected: " + expected); System.err.println("\tActual: " + gcInsets); } f.dispose(); } if (!passed) { throw new RuntimeException("TEST FAILED: Toolkit.getScreenInsets() returns wrong value for some screens"); } }