List of usage examples for java.awt GraphicsConfiguration getDevice
public abstract GraphicsDevice getDevice();
From source file:Main.java
public static void main(String[] argv) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gs = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gs.getDefaultConfiguration(); System.out.println(gc.getDevice()); }
From source file:Main.java
public static void main(String[] args) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice defaultScreen = ge.getDefaultScreenDevice(); GraphicsConfiguration[] configurations = defaultScreen.getConfigurations(); System.out.println("Default screen device: " + defaultScreen.getIDstring()); for (int i = 0; i < configurations.length; i++) { System.out.println(" Configuration " + (i + 1)); GraphicsConfiguration c = configurations[i]; System.out.println(" " + c.getColorModel()); System.out.println(" " + c.getBounds()); System.out.println(" " + c.getBufferCapabilities()); System.out.println(" " + c.getDefaultTransform()); System.out.println(" " + c.getDevice()); }/*from w w w. j av a 2s .co m*/ }
From source file:Main.java
public static int getMonitor(Component c) { Window w = (c instanceof Window) ? (Window) c : SwingUtilities.windowForComponent(c); GraphicsConfiguration gc = (w == null) ? null : w.getGraphicsConfiguration(); GraphicsDevice gd = (gc == null) ? null : gc.getDevice(); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); for (int i = 0; i < gs.length; i++) { if (gs[i].equals(gd)) { return i; }//from w ww .j a v a2 s. c o m } return -1; }
From source file:net.pms.newgui.components.WindowProperties.java
/** * Creates a new instance using the specified parameters. * * @param window the {@link Window} whose properties to keep track of. * @param standardSize the standard size of {@code window}. * @param mimimumSize the minimum size of {@code window}. * @param windowConfiguration the {@link WindowPropertiesConfiguration} * instance for reading and writing the window properties. *//*from w ww . j a v a2s. c o m*/ public WindowProperties(@Nonnull Window window, @Nullable Dimension standardSize, @Nullable Dimension mimimumSize, @Nullable WindowPropertiesConfiguration windowConfiguration) { if (window == null) { throw new IllegalArgumentException("window cannot be null"); } this.window = window; this.minimumSize = mimimumSize; if (mimimumSize != null) { window.setMinimumSize(mimimumSize); } this.windowConfiguration = windowConfiguration; if (windowConfiguration != null) { getConfiguration(); GraphicsConfiguration windowGraphicsConfiguration = window.getGraphicsConfiguration(); if (windowBounds != null && effectiveScreenBounds != null && graphicsDevice != null && graphicsDevice.equals(windowGraphicsConfiguration.getDevice().getIDstring()) && screenBounds != null && screenBounds.equals(windowGraphicsConfiguration.getBounds())) { setWindowBounds(); } else { Rectangle screen = effectiveScreenBounds != null ? effectiveScreenBounds : windowGraphicsConfiguration.getBounds(); if (standardSize != null && screen.width >= standardSize.width && screen.height >= standardSize.height) { window.setSize(standardSize); } else if (mimimumSize != null && (window.getWidth() < mimimumSize.width || window.getHeight() < mimimumSize.getHeight())) { window.setSize(mimimumSize); } window.setLocationByPlatform(true); } if (window instanceof Frame) { // Set maximized state int maximizedState = windowState & Frame.MAXIMIZED_BOTH; if (maximizedState != 0) { ((Frame) window).setExtendedState(((Frame) window).getExtendedState() | maximizedState); } } } window.addWindowListener(this); window.addComponentListener(this); }
From source file:com.igormaznitsa.sciareto.ui.MainFrame.java
private void menuFullScreenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuFullScreenActionPerformed final Component currentComponent = this.tabPane.getSelectedComponent(); if (!(currentComponent instanceof Container)) { LOGGER.warn("Detected attempt to full screen not a container : " + currentComponent); return;// w w w. j av a 2s . c om } final GraphicsConfiguration gconfig = this.getGraphicsConfiguration(); if (gconfig != null) { final GraphicsDevice device = gconfig.getDevice(); if (device.isFullScreenSupported()) { if (device.getFullScreenWindow() == null) { final JLabel label = new JLabel("Opened in full screen"); final int tabIndex = this.tabPane.getSelectedIndex(); this.tabPane.setComponentAt(tabIndex, label); final JWindow window = new JWindow(Main.getApplicationFrame()); window.setAlwaysOnTop(true); window.setContentPane((Container) currentComponent); endFullScreenIfActive(); final KeyEventDispatcher fullScreenEscCatcher = new KeyEventDispatcher() { @Override public boolean dispatchKeyEvent(@Nonnull final KeyEvent e) { if (e.getID() == KeyEvent.KEY_PRESSED && (e.getKeyCode() == KeyEvent.VK_ESCAPE || e.getKeyCode() == KeyEvent.VK_F11)) { endFullScreenIfActive(); return true; } return false; } }; if (this.taskToEndFullScreen.compareAndSet(null, new Runnable() { @Override public void run() { try { window.dispose(); } finally { tabPane.setComponentAt(tabIndex, currentComponent); device.setFullScreenWindow(null); KeyboardFocusManager.getCurrentKeyboardFocusManager() .removeKeyEventDispatcher(fullScreenEscCatcher); } } })) { try { KeyboardFocusManager.getCurrentKeyboardFocusManager() .addKeyEventDispatcher(fullScreenEscCatcher); device.setFullScreenWindow(window); } catch (Exception ex) { LOGGER.error("Can't turn on full screen", ex); endFullScreenIfActive(); KeyboardFocusManager.getCurrentKeyboardFocusManager() .removeKeyEventDispatcher(fullScreenEscCatcher); } } else { LOGGER.error("Unexpected state, processor is not null!"); } } else { LOGGER.warn("Attempt to full screen device which already in full screen!"); } } else { LOGGER.warn("Device doesn's support full screen"); DialogProviderManager.getInstance().getDialogProvider() .msgWarn("The Device doesn't support full-screen mode!"); } } else { LOGGER.warn("Can't find graphics config for the frame"); } }
From source file:org.pentaho.reporting.designer.core.actions.global.ScreenCaptureAction.java
public static void saveScreenShot(final int modifiers) { final Component component = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow(); final GraphicsConfiguration graphicsConfiguration = component.getGraphicsConfiguration(); final GraphicsDevice graphicsDevice = graphicsConfiguration.getDevice(); try {/* w ww . j ava 2 s. c o m*/ final Robot robot = new Robot(graphicsDevice); final BufferedImage image; if ((modifiers & ActionEvent.SHIFT_MASK) == ActionEvent.SHIFT_MASK) { image = robot.createScreenCapture(graphicsConfiguration.getBounds()); } else { image = robot.createScreenCapture(component.getBounds()); } final String homeDirectory = ReportDesignerBoot.getInstance().getGlobalConfig() .getConfigProperty("user.home", "."); final File homeDir = new File(homeDirectory); final File f = generateName(homeDir); if (f == null) { return; } final FileOutputStream fout = new FileOutputStream(f); try { final PngEncoder encoder = new PngEncoder(); encoder.setCompressionLevel(6); encoder.setEncodeAlpha(false); encoder.setImage(image); final byte[] bytes = encoder.pngEncode(); fout.write(bytes); } finally { fout.close(); } } catch (IOException ioe) { UncaughtExceptionsModel.getInstance().addException(ioe); } catch (AWTException e1) { // ignore UncaughtExceptionsModel.getInstance().addException(e1); } }