Java Code Examples for java.awt.GraphicsDevice#setFullScreenWindow()

The following examples show how to use java.awt.GraphicsDevice#setFullScreenWindow() . 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: DisplayChangeVITest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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.");
    }
}
 
Example 2
Source File: DisplayChangeVITest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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.");
    }
}
 
Example 3
Source File: DisplayChangeVITest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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.");
    }
}
 
Example 4
Source File: BufferStrategyExceptionTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    GraphicsDevice gd =
        GraphicsEnvironment.getLocalGraphicsEnvironment().
            getDefaultScreenDevice();

    for (int i = 0; i < TEST_REPS; i++) {
        TestFrame f = new TestFrame();
        f.pack();
        f.setSize(400, 400);
        f.setVisible(true);
        if (i % 2 == 0) {
            gd.setFullScreenWindow(f);
        }
        // generate a resize event which will invalidate the peer's
        // surface data and hopefully cause an exception during
        // BufferStrategy creation in TestFrame.render()
        Dimension d = f.getSize();
        d.width -= 5; d.height -= 5;
        f.setSize(d);

        f.render();
        gd.setFullScreenWindow(null);
        sleep(100);
        f.dispose();
    }
    System.out.println("Test passed.");
}
 
Example 5
Source File: BufferStrategyExceptionTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    GraphicsDevice gd =
        GraphicsEnvironment.getLocalGraphicsEnvironment().
            getDefaultScreenDevice();

    for (int i = 0; i < TEST_REPS; i++) {
        TestFrame f = new TestFrame();
        f.pack();
        f.setSize(400, 400);
        f.setVisible(true);
        if (i % 2 == 0) {
            gd.setFullScreenWindow(f);
        }
        // generate a resize event which will invalidate the peer's
        // surface data and hopefully cause an exception during
        // BufferStrategy creation in TestFrame.render()
        Dimension d = f.getSize();
        d.width -= 5; d.height -= 5;
        f.setSize(d);

        f.render();
        gd.setFullScreenWindow(null);
        sleep(100);
        f.dispose();
    }
    System.out.println("Test passed.");
}
 
Example 6
Source File: BufferStrategyExceptionTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    GraphicsDevice gd =
        GraphicsEnvironment.getLocalGraphicsEnvironment().
            getDefaultScreenDevice();

    for (int i = 0; i < TEST_REPS; i++) {
        TestFrame f = new TestFrame();
        f.pack();
        f.setSize(400, 400);
        f.setVisible(true);
        if (i % 2 == 0) {
            gd.setFullScreenWindow(f);
        }
        // generate a resize event which will invalidate the peer's
        // surface data and hopefully cause an exception during
        // BufferStrategy creation in TestFrame.render()
        Dimension d = f.getSize();
        d.width -= 5; d.height -= 5;
        f.setSize(d);

        f.render();
        gd.setFullScreenWindow(null);
        sleep(100);
        f.dispose();
    }
    System.out.println("Test passed.");
}
 
Example 7
Source File: BufferStrategyExceptionTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    GraphicsDevice gd =
        GraphicsEnvironment.getLocalGraphicsEnvironment().
            getDefaultScreenDevice();

    for (int i = 0; i < TEST_REPS; i++) {
        TestFrame f = new TestFrame();
        f.pack();
        f.setSize(400, 400);
        f.setVisible(true);
        if (i % 2 == 0) {
            gd.setFullScreenWindow(f);
        }
        // generate a resize event which will invalidate the peer's
        // surface data and hopefully cause an exception during
        // BufferStrategy creation in TestFrame.render()
        Dimension d = f.getSize();
        d.width -= 5; d.height -= 5;
        f.setSize(d);

        f.render();
        gd.setFullScreenWindow(null);
        sleep(100);
        f.dispose();
    }
    System.out.println("Test passed.");
}
 
Example 8
Source File: NBodyVisualizer.java    From gpu-nbody with MIT License 5 votes vote down vote up
/**
 * Sets the window to fullscreen.
 */
private void setFullscreen() {
	final GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
	final GraphicsDevice[] devices = env.getScreenDevices();

	final GraphicsDevice device = devices[0];

	device.setFullScreenWindow(frame);
}
 
Example 9
Source File: BufferStrategyExceptionTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    GraphicsDevice gd =
        GraphicsEnvironment.getLocalGraphicsEnvironment().
            getDefaultScreenDevice();

    for (int i = 0; i < TEST_REPS; i++) {
        TestFrame f = new TestFrame();
        f.pack();
        f.setSize(400, 400);
        f.setVisible(true);
        if (i % 2 == 0) {
            gd.setFullScreenWindow(f);
        }
        // generate a resize event which will invalidate the peer's
        // surface data and hopefully cause an exception during
        // BufferStrategy creation in TestFrame.render()
        Dimension d = f.getSize();
        d.width -= 5; d.height -= 5;
        f.setSize(d);

        f.render();
        gd.setFullScreenWindow(null);
        sleep(100);
        f.dispose();
    }
    System.out.println("Test passed.");
}
 
Example 10
Source File: BufferStrategyExceptionTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    GraphicsDevice gd =
        GraphicsEnvironment.getLocalGraphicsEnvironment().
            getDefaultScreenDevice();

    for (int i = 0; i < TEST_REPS; i++) {
        TestFrame f = new TestFrame();
        f.pack();
        f.setSize(400, 400);
        f.setVisible(true);
        if (i % 2 == 0) {
            gd.setFullScreenWindow(f);
        }
        // generate a resize event which will invalidate the peer's
        // surface data and hopefully cause an exception during
        // BufferStrategy creation in TestFrame.render()
        Dimension d = f.getSize();
        d.width -= 5; d.height -= 5;
        f.setSize(d);

        f.render();
        gd.setFullScreenWindow(null);
        sleep(100);
        f.dispose();
    }
    System.out.println("Test passed.");
}
 
Example 11
Source File: BufferStrategyExceptionTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    GraphicsDevice gd =
        GraphicsEnvironment.getLocalGraphicsEnvironment().
            getDefaultScreenDevice();

    for (int i = 0; i < TEST_REPS; i++) {
        TestFrame f = new TestFrame();
        f.pack();
        f.setSize(400, 400);
        f.setVisible(true);
        if (i % 2 == 0) {
            gd.setFullScreenWindow(f);
        }
        // generate a resize event which will invalidate the peer's
        // surface data and hopefully cause an exception during
        // BufferStrategy creation in TestFrame.render()
        Dimension d = f.getSize();
        d.width -= 5; d.height -= 5;
        f.setSize(d);

        f.render();
        gd.setFullScreenWindow(null);
        sleep(100);
        f.dispose();
    }
    System.out.println("Test passed.");
}
 
Example 12
Source File: NbPresenter.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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();
    }
}
 
Example 13
Source File: Utils.java    From DroidUIBuilder with Apache License 2.0 5 votes vote down vote up
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 14
Source File: BufferStrategyExceptionTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    GraphicsDevice gd =
        GraphicsEnvironment.getLocalGraphicsEnvironment().
            getDefaultScreenDevice();

    for (int i = 0; i < TEST_REPS; i++) {
        TestFrame f = new TestFrame();
        f.pack();
        f.setSize(400, 400);
        f.setVisible(true);
        if (i % 2 == 0) {
            gd.setFullScreenWindow(f);
        }
        // generate a resize event which will invalidate the peer's
        // surface data and hopefully cause an exception during
        // BufferStrategy creation in TestFrame.render()
        Dimension d = f.getSize();
        d.width -= 5; d.height -= 5;
        f.setSize(d);

        f.render();
        gd.setFullScreenWindow(null);
        sleep(100);
        f.dispose();
    }
    System.out.println("Test passed.");
}
 
Example 15
Source File: FullScreenInsets.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
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 16
Source File: FullScreenInsets.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
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 17
Source File: MainFrame.java    From netbeans-mmd-plugin with Apache License 2.0 4 votes vote down vote up
private void menuFullScreenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuFullScreenActionPerformed

    final AbstractEditor selectedEditor = this.tabPane.getCurrentEditor();
    if (selectedEditor != null) {
      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.setAutoRequestFocus(true);
            window.setContentPane(selectedEditor.getContainerToShow());

            endFullScreenIfActive();

            final KeyEventDispatcher fullScreenEscCatcher = (@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, (Runnable) () -> {
              try {
                window.dispose();
              } finally {
                tabPane.setComponentAt(tabIndex, selectedEditor.getContainerToShow());
                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); //NOI18N
                endFullScreenIfActive();
                KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventDispatcher(fullScreenEscCatcher);
              }
            } else {
              LOGGER.error("Unexpected state, processor is not null!"); //NOI18N
            }
          } else {
            LOGGER.warn("Attempt to full screen device which already in full screen!"); //NOI18N
          }
        } else {
          LOGGER.warn("Device doesn's support full screen"); //NOI18N
          DialogProviderManager.getInstance().getDialogProvider().msgWarn(this, "The Device doesn't support full-screen mode!");
        }
      } else {
        LOGGER.warn("Can't find graphics config for the frame"); //NOI18N
      }
    }
  }
 
Example 18
Source File: FullScreenInsets.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
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 19
Source File: FullScreenInsets.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
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: FullScreenInsets.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
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");
    }
}