List of usage examples for java.awt GraphicsDevice getFullScreenWindow
public Window getFullScreenWindow()
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;/*from www . ja va2 s. co m*/ } 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.rdv.datapanel.AbstractDataPanel.java
/** * Undock the UI component and display fullscreen. * /* w w w. ja va 2 s . co m*/ * @since 1.1 */ void maximizePanel() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] devices = ge.getScreenDevices(); for (int i = 0; i < devices.length; i++) { GraphicsDevice device = devices[i]; if (device.isFullScreenSupported() && device.getFullScreenWindow() == null) { maximized = true; dataPanelContainer.removeDataPanel(component); frame = new JFrame(getTitle()); frame.setUndecorated(true); frame.getContentPane().add(component); try { device.setFullScreenWindow(frame); } catch (InternalError e) { log.error("Failed to switch to full screen mode: " + e.getMessage() + "."); restorePanel(true); return; } frame.setVisible(true); frame.requestFocus(); return; } } log.warn("No screens available or full screen exclusive mode is unsupported on your platform."); }
From source file:org.rdv.datapanel.AbstractDataPanel.java
/** * Leave fullscreen mode and dock the UI component if addToContainer is true. * // w w w. j av a2 s .c o m * @param addToContainer whether to dock the UI component * @since 1.1 */ void restorePanel(boolean addToContainer) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] devices = ge.getScreenDevices(); for (int i = 0; i < devices.length; i++) { GraphicsDevice device = devices[i]; if (device.isFullScreenSupported() && device.getFullScreenWindow() == frame) { if (frame != null) { frame.setVisible(false); device.setFullScreenWindow(null); frame.getContentPane().remove(component); frame.dispose(); frame = null; } maximized = false; if (addToContainer) { dataPanelContainer.addDataPanel(component); } break; } } }
From source file:org.rdv.ui.MainPanel.java
private boolean enterFullScreenMode() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] devices = ge.getScreenDevices(); for (int i = 0; i < devices.length; i++) { GraphicsDevice device = devices[i]; if (device.isFullScreenSupported() && device.getFullScreenWindow() == null) { log.info("Switching to full screen mode."); frame.setVisible(false);/*w w w. ja v a 2s . c o m*/ try { device.setFullScreenWindow(frame); } catch (InternalError e) { log.error("Failed to switch to full screen exclusive mode."); e.printStackTrace(); frame.setVisible(true); return false; } frame.dispose(); frame.setUndecorated(true); frame.setVisible(true); frame.requestFocusInWindow(); return true; } } log.warn("No screens available or full screen exclusive mode is unsupported on your platform."); postError("Full screen mode is not supported on your platform."); return false; }
From source file:org.rdv.ui.MainPanel.java
private void leaveFullScreenMode() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] devices = ge.getScreenDevices(); for (int i = 0; i < devices.length; i++) { GraphicsDevice device = devices[i]; if (device.isFullScreenSupported() && device.getFullScreenWindow() == frame) { log.info("Leaving full screen mode."); frame.setVisible(false);// w w w . j ava 2 s.c om device.setFullScreenWindow(null); frame.dispose(); frame.setUndecorated(false); frame.setVisible(true); break; } } }
From source file:org.simmi.GeneSetHead.java
License:asdf
public void initFSKeyListener(final Window window) { keylistener = new KeyListener() { @Override//from w w w .j a va 2 s. c om public void keyTyped(KeyEvent e) { } @Override public void keyReleased(KeyEvent e) { } @Override public void keyPressed(KeyEvent e) { GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); if (e.getKeyCode() == KeyEvent.VK_F11 && gd.isFullScreenSupported()) { Window w = gd.getFullScreenWindow(); if (w != null) { gd.setFullScreenWindow(null); } else { gd.setFullScreenWindow(window); } } } }; }