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); } } }
@Override public void start(final Stage stage) throws Exception { GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); int width = gd.getDisplayMode().getWidth(); int height = gd.getDisplayMode().getHeight(); Scene scene = new Scene(FXMLLoader.load(UDEDesktop.class.getResource("resources/UDEDesktopWindow.fxml")), width, height); scene.setFill(null); scene.getStylesheets().add("resources/stylesheet.css"); stage.setScene(scene); // stage.initStyle(StageStyle.UNDECORATED); stage.initStyle(StageStyle.TRANSPARENT); stage.setTitle("UDEDesktop"); stage.setMinWidth(300); stage.setMinHeight(300); stage.show(); stage.toBack(); }
public static void main(final String[] args) { final GraphicsEnvironment lge = getLocalGraphicsEnvironment(); final GraphicsDevice dev = lge.getDefaultScreenDevice(); final GraphicsConfiguration config = dev.getDefaultConfiguration(); test(config.createCompatibleImage(10, 10).getGraphics()); test(config.createCompatibleImage(10, 10, OPAQUE).getGraphics()); test(config.createCompatibleImage(10, 10, BITMASK).getGraphics()); test(config.createCompatibleImage(10, 10, TRANSLUCENT).getGraphics()); test(new BufferedImage(10, 10, TYPE_INT_ARGB).getGraphics()); final Window frame = new Frame(); frame.pack(); try { test(frame.getGraphics()); test(frame.createImage(10, 10).getGraphics()); } finally { frame.dispose(); } }
public void setVisible(boolean visible) { if (owner == null) { final GraphicsDevice screen = GraphicsEnvironment. getLocalGraphicsEnvironment(). getScreenDevices()[0]; final GraphicsConfiguration config = screen.getDefaultConfiguration(); final int screenWidth = config.getBounds().width; final int screenHeight = config.getBounds().height; setLocation( (screenWidth - getSize().width) / 2, (screenHeight - getSize().height) / 2); } else { setLocation( owner.getLocation().x + DIALOG_FRAME_WIDTH_DELTA, owner.getLocation().y + DIALOG_FRAME_WIDTH_DELTA); } super.setVisible(visible); }
public static void main(String[] args) throws InterruptedException, InvocationTargetException { SwingUtilities.invokeAndWait(() -> { JFrame f = new JFrame(); f.setUndecorated(true); GraphicsDevice gd = f.getGraphicsConfiguration().getDevice(); if (gd.isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSLUCENT)) { f.setBackground(new Color(0, 0, 0, 0)); } f.setSize(200, 300); f.setVisible(true); try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); } catch (Exception e) { System.err.println(e); System.err.println("Could not set GTKLookAndFeel, skipping this test"); } finally { f.dispose(); } }); }
public void show(Point location) { Rectangle screenBounds = null; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gds = ge.getScreenDevices(); for (GraphicsDevice device : gds) { GraphicsConfiguration gc = device.getDefaultConfiguration(); screenBounds = gc.getBounds(); if (screenBounds.contains(location)) { break; } } // showing the popup tooltip cp = new TooltipContentPanel(master.getTextComponent()); Window w = SwingUtilities.windowForComponent(master.getTextComponent()); contentWindow = new JWindow(w); contentWindow.add(cp); contentWindow.pack(); Dimension dim = contentWindow.getSize(); if (location.y + dim.height + SCREEN_BORDER > screenBounds.y + screenBounds.height) { dim.height = (screenBounds.y + screenBounds.height) - (location.y + SCREEN_BORDER); } if (location.x + dim.width + SCREEN_BORDER > screenBounds.x + screenBounds.width) { dim.width = (screenBounds.x + screenBounds.width) - (location.x + SCREEN_BORDER); } contentWindow.setSize(dim); contentWindow.setLocation(location.x, location.y - 1); // slight visual adjustment contentWindow.setVisible(true); Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK); w.addWindowFocusListener(this); contentWindow.addWindowFocusListener(this); }
@Override public void setWindowAlpha(Window w, float alpha) { GraphicsConfiguration gc = w.getGraphicsConfiguration(); GraphicsDevice gd = gc.getDevice(); if (gc.getDevice().getFullScreenWindow() == w) { return; } if (!gd.isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency.TRANSLUCENT)) { return; } w.setOpacity(alpha); }
public static void main(String[] args) throws Exception { GraphicsDevice[] sds = GraphicsEnvironment.getLocalGraphicsEnvironment() .getScreenDevices(); for (final GraphicsDevice gd : sds) { fail = true; Robot robot = new Robot(gd); robot.setAutoDelay(100); robot.setAutoWaitForIdle(true); Frame frame = new Frame(gd.getDefaultConfiguration()); frame.setUndecorated(true); frame.setSize(400, 400); frame.setVisible(true); robot.waitForIdle(); frame.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { System.out.println("e = " + e); fail = false; } }); Rectangle bounds = frame.getBounds(); robot.mouseMove(bounds.x + bounds.width / 2, bounds.y + bounds.height / 2); robot.mousePress(MouseEvent.BUTTON1_DOWN_MASK); robot.mouseRelease(MouseEvent.BUTTON1_DOWN_MASK); frame.dispose(); if (fail) { System.err.println("Frame bounds = " + bounds); throw new RuntimeException("Click in the wrong location"); } } }
/** * Returns an array of screens that are available on the current system * * @return */ public static ScreenModel[] getScreens() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gd = ge.getScreenDevices(); ScreenModel[] models = new ScreenModel[gd.length]; for (int i = 0; i < gd.length; i++) { if (gd[i].getIDstring().equals(getDefaultScreenId())) { models[i] = new ScreenModel(gd[i], "(" + I18n.get("settings.mainscreen") + ")", i + 1); } else { models[i] = new ScreenModel(gd[i], "", i + 1); } } return models; }
/** * 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(); }
/** * hack from * https://bulenkov.com/2013/06/23/retina-support-in-oracle-jdk-1-7/ used to * multiply mouse coordinates by two in case of retina display; see * http://forum.lwjgl.org/index.php?topic=5084.0 * * @return true if running on platform with retina display. Value is cached * in VM to avoid runtime cost penalty of multiple calls. */ public static boolean hasAppleRetinaDisplay() { if (checkedRetinaDisplay) { return hasRetinaDisplayTrue; } checkedRetinaDisplay = true; //other OS and JVM specific checks... GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); final GraphicsDevice device = env.getDefaultScreenDevice(); try { Field field = device.getClass().getDeclaredField("scale"); if (field != null) { field.setAccessible(true); Object scale = field.get(device); if (scale instanceof Integer && ((Integer) scale).intValue() == 2) { hasRetinaDisplayTrue = true; } } } catch (Exception ignore) { } //... return hasRetinaDisplayTrue; }
/** * Finds a display mode that is different from the current display * mode and is likely to cause a display change event. */ private static DisplayMode findDisplayMode(GraphicsDevice gd) { DisplayMode dms[] = gd.getDisplayModes(); DisplayMode currentDM = gd.getDisplayMode(); for (DisplayMode dm : dms) { if (!dm.equals(currentDM) && dm.getRefreshRate() == currentDM.getRefreshRate()) { // different from the current dm and refresh rate is the same // means that something else is different => more likely to // cause a DM change event return dm; } } return null; }
@Override public GraphicsDevice getGraphicsDevice() { CGraphicsEnvironment ge = (CGraphicsEnvironment)GraphicsEnvironment. getLocalGraphicsEnvironment(); LWLightweightFramePeer peer = (LWLightweightFramePeer)getPeer(); int scale = ((LightweightFrame)peer.getTarget()).getScaleFactor(); Rectangle bounds = ((LightweightFrame)peer.getTarget()).getHostBounds(); for (GraphicsDevice d : ge.getScreenDevices()) { if (d.getDefaultConfiguration().getBounds().intersects(bounds) && ((CGraphicsDevice)d).getScaleFactor() == scale) { return d; } } // We shouldn't be here... return ge.getDefaultScreenDevice(); }
static void initScreenBounds() { GraphicsDevice[] devices = GraphicsEnvironment .getLocalGraphicsEnvironment() .getScreenDevices(); screenBounds = new Rectangle[devices.length]; scales = new double[devices.length][2]; for (int i = 0; i < devices.length; i++) { GraphicsConfiguration gc = devices[i].getDefaultConfiguration(); screenBounds[i] = gc.getBounds(); AffineTransform tx = gc.getDefaultTransform(); scales[i][0] = tx.getScaleX(); scales[i][1] = tx.getScaleY(); } for (int i = 0; i < devices.length; i++) { for (int j = i + 1; j < devices.length; j++) { if (scales[i][0] != scales[j][0] || scales[i][1] != scales[j][1]) { screen1 = i; screen2 = j; } } } }
private void executeTest() { GraphicsDevice defDev = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); int x = 0; Frame f = null; for (x = 0; x < gd.length; x ++) { if (gd[x] != defDev) { secFrame = new Frame("Screen " + x + " - secondary", gd[x].getDefaultConfiguration()); f = secFrame; } else { primaryFrame = new Frame("Screen " + x + " - primary", gd[x].getDefaultConfiguration()); f = primaryFrame; } Button b = new Button("Print"); b.addActionListener(this); f.add("South", b); f.addWindowListener (new WindowAdapter() { public void windowClosing(WindowEvent we) { ((Window) we.getSource()).dispose(); } }); f.setSize(200, 200); f.setVisible(true); } }
public Viewer() throws Exception{ setShowSettings(false); AppSettings settings=new AppSettings(true); settings.setResizable(true); settings.setFrameRate(15); settings.setWidth(640); settings.setHeight(480); settings.setTitle("Image Viewer"); reloadImage(null); int w=IMAGE.getImage().getWidth(); int h=IMAGE.getImage().getHeight(); GraphicsDevice gd=GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); if(w<gd.getDisplayMode().getWidth()/2&&h<gd.getDisplayMode().getHeight()){ settings.setWidth(w); settings.setHeight(h); } setSettings(settings); }
public static void main(String[] args) throws Exception { DisplayChangeVITest test = new DisplayChangeVITest(); GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment(). getDefaultScreenDevice(); if (gd.isFullScreenSupported()) { gd.setFullScreenWindow(test); Thread t = new Thread(test); t.run(); synchronized (lock) { while (!done) { try { lock.wait(50); } catch (InterruptedException ex) { ex.printStackTrace(); } } } System.err.println("Test Passed."); } else { System.err.println("Full screen not supported. Test passed."); } }
/** */ public void showBoard() { if (0 != cfg.getInt("device", 0)) { GraphicsDevice[] screenDevices = GraphicsEnvironment.getLocalGraphicsEnvironment() .getScreenDevices(); int i = 1; for (GraphicsDevice graphicsDevice : screenDevices) { System.out.println( "graphicsDevice = " + graphicsDevice.getIDstring() + " " + graphicsDevice .toString() + "\nРазрешение экрана " + graphicsDevice.getDefaultConfiguration() .getBounds().height + "x" + graphicsDevice.getDefaultConfiguration() .getBounds().width + "\nГлубина цвета " + graphicsDevice.getDisplayMode().getBitDepth() + "\nЧастота " + graphicsDevice.getDisplayMode().getRefreshRate() + "\nНачало координат " + graphicsDevice.getDefaultConfiguration() .getBounds().x + "-" + graphicsDevice.getDefaultConfiguration().getBounds().y); if (i == cfg.getInt("device")) { win_x = graphicsDevice.getDefaultConfiguration().getBounds().x; win_y = graphicsDevice.getDefaultConfiguration().getBounds().y; win_w = graphicsDevice.getDefaultConfiguration().getBounds().width; win_h = graphicsDevice.getDefaultConfiguration().getBounds().height; } i++; } SwingUtilities.invokeLater(() -> { initAndShowGUI(); }); } }
public static BufferedImage getCompatibleImage(final int width, final int height) { if (width == 0 && height == 0) { return null; } final GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); final GraphicsDevice device = env.getDefaultScreenDevice(); final GraphicsConfiguration config = device.getDefaultConfiguration(); return config.createCompatibleImage(width, height, Transparency.TRANSLUCENT); }
public static void main(final String[] args) throws InvocationTargetException, InterruptedException { SwingUtilities.invokeAndWait(() -> { final GraphicsDevice[] devices = GraphicsEnvironment.getLocalGraphicsEnvironment() .getScreenDevices(); final Frame frame = new Frame(); frame.setBackground(Color.GREEN); frame.setUndecorated(true); frame.setSize(100, 100); frame.setLocationRelativeTo(null); frame.setVisible(true); sleep(); for (final GraphicsDevice gd : devices) { try { gd.setFullScreenWindow(frame); if (gd.getFullScreenWindow() != frame) { throw new RuntimeException("Wrong window"); } if (frame.getGraphicsConfiguration().getDevice() != gd) { throw new RuntimeException("Wrong new GraphicsDevice"); } } finally { // cleaning up gd.setFullScreenWindow(null); } } frame.dispose(); }); }
private Rectangle[] getScreenBounds() { GraphicsDevice[] gds = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); List<Rectangle> rects = new ArrayList<Rectangle>(gds.length); for (GraphicsDevice gd : gds) { GraphicsConfiguration gc = gd.getDefaultConfiguration(); rects.add(Utilities.getUsableScreenBounds(gc)); } return rects.toArray(new Rectangle[rects.size()]); }
void show(Point location) { Rectangle screenBounds = null; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gds = ge.getScreenDevices(); for (GraphicsDevice device : gds) { GraphicsConfiguration gc = device.getDefaultConfiguration(); screenBounds = gc.getBounds(); if (screenBounds.contains(location)) { break; } } // showing the popup tooltip cp = new TooltipContentPanel(); Window w = SwingUtilities.windowForComponent(parent); contentWindow = new JWindow(w); contentWindow.add(cp); contentWindow.pack(); Dimension dim = contentWindow.getSize(); if (screenBounds.width + screenBounds.x - location.x < cp.longestLine) { // the whole window does fully not fit to the right // the x position where the window has to start to fully fit to the right int left = screenBounds.width + screenBounds.x - cp.longestLine; // the window should have x pos minimally at the screen's start location.x = Math.max(screenBounds.x, left); } if (location.y + dim.height + SCREEN_BORDER > screenBounds.y + screenBounds.height) { dim.height = (screenBounds.y + screenBounds.height) - (location.y + SCREEN_BORDER); } if (location.x + dim.width + SCREEN_BORDER > screenBounds.x + screenBounds.width) { dim.width = (screenBounds.x + screenBounds.width) - (location.x + SCREEN_BORDER); } contentWindow.setSize(dim); contentWindow.setLocation(location.x, location.y + 1); // slight visual adjustment contentWindow.setVisible(true); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { cp.scrollRectToVisible(new Rectangle(1, 1)); } }); Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK); w.addWindowFocusListener(this); contentWindow.addWindowFocusListener(this); contentWindow.addKeyListener(this); w.addKeyListener(this); }
/** * @return False if the given point is not inside any screen device that are currently available. */ private static boolean isOutOfScreen( int x, int y ) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); for( int j=0; j<gs.length; j++ ) { GraphicsDevice gd = gs[j]; if( gd.getType() != GraphicsDevice.TYPE_RASTER_SCREEN ) continue; Rectangle bounds = gd.getDefaultConfiguration().getBounds(); if( bounds.contains( x, y ) ) return false; } return true; }
private Rectangle getScreenBounds() { Rectangle res = null; PointerInfo pi = MouseInfo.getPointerInfo(); if( null != pi ) { GraphicsDevice gd = pi.getDevice(); if( gd != null ) { GraphicsConfiguration gc = gd.getDefaultConfiguration(); if( gc != null ) { res = gc.getBounds(); } } } return res; }
private static VolatileImage makeVI(final int type) { final GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); final GraphicsDevice gd = ge.getDefaultScreenDevice(); final GraphicsConfiguration gc = gd.getDefaultConfiguration(); return gc.createCompatibleVolatileImage(SIZE, SIZE, type); }
private void doShow () { //#206802 - dialog windows are hidden behind full screen window Window fullScreenWindow = null; if( Utilities.isUnix() ) { GraphicsDevice gd = getGraphicsConfiguration().getDevice(); if( gd.isFullScreenSupported() ) { fullScreenWindow = gd.getFullScreenWindow(); if( null != fullScreenWindow ) gd.setFullScreenWindow( null ); } } NbPresenter prev = null; try { MenuSelectionManager.defaultManager().clearSelectedPath(); } catch( NullPointerException npE ) { //#216184 LOG.log( Level.FINE, null, npE ); } if (isModal()) { prev = currentModalDialog; currentModalDialog = this; fireChangeEvent(); } superShow(); if( null != fullScreenWindow ) getGraphicsConfiguration().getDevice().setFullScreenWindow( fullScreenWindow ); if (currentModalDialog != prev) { currentModalDialog = prev; fireChangeEvent(); } }
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!"); }
private DisplayMode findDisplayMode() { GraphicsDevice gd = getGraphicsConfiguration().getDevice(); DisplayMode dms[] = gd.getDisplayModes(); DisplayMode currentDM = gd.getDisplayMode(); for (DisplayMode dm : dms) { if (dm.getBitDepth() > 8 && dm.getBitDepth() != DisplayMode.BIT_DEPTH_MULTI && dm.getBitDepth() != currentDM.getBitDepth() && dm.getWidth() == currentDM.getWidth() && dm.getHeight() == currentDM.getHeight()) { // found a mode which has the same dimensions but different // depth return dm; } if (dm.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI && (dm.getWidth() != currentDM.getWidth() || dm.getHeight() != currentDM.getHeight())) { // found a mode which has the same depth but different // dimensions return dm; } } return null; }
private void setupDimensions(boolean spanMultipleMonitors) { if (spanMultipleMonitors) { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); m_width = screenSize.width; m_height = screenSize.height; } else { GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); m_width = gd.getDisplayMode().getWidth(); m_height = gd.getDisplayMode().getHeight(); } }
public static void main() { // 全屏运行 RectD rd = new RectD(); GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment() .getDefaultScreenDevice(); gd.setFullScreenWindow(rd); System.out.println("main方法中的截图名:"+ rd.name); //return rd.name; }
/** * 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 config = devices[i].getDefaultConfiguration(); Rectangle gcBounds = config.getBounds(); if (gcBounds.contains(x, y)) { return gcBounds; } } // If point is outside all monitors, default to default monitor (?) return env.getMaximumWindowBounds(); }
private static boolean isReallyHeadless() { if (GraphicsEnvironment.isHeadless()) { //return true; } try { GraphicsDevice[] screenDevices = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); return screenDevices == null || screenDevices.length == 0; } catch (HeadlessException e) { System.err.print(e); return true; } }
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(); } } }
/** * Return the bounds of a GraphicsDevice, less its screen insets. * See also java.awt.GraphicsEnvironment.getUsableBounds(); */ public static Rectangle getUsableBounds(GraphicsDevice gd) { GraphicsConfiguration gc = gd.getDefaultConfiguration(); Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc); Rectangle usableBounds = gc.getBounds(); usableBounds.x += insets.left; usableBounds.y += insets.top; usableBounds.width -= (insets.left + insets.right); usableBounds.height -= (insets.top + insets.bottom); return usableBounds; }
/** * From the DisplayChangedListener interface; called * when the display mode has been changed. */ public void displayChanged() { // notify screens in device array to do display update stuff for (GraphicsDevice gd : getScreenDevices()) { if (gd instanceof DisplayChangedListener) { ((DisplayChangedListener) gd).displayChanged(); } } // notify SunDisplayChanger list (e.g. VolatileSurfaceManagers and // SurfaceDataProxies) about the display change event displayChanger.notifyListeners(); }
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); } } }
public FrameListener(GraphicsDevice device, CountDownLatch latch, boolean [] result) { this.device = device; this.latch = latch; this.result = result; }