Example usage for javax.swing JFrame createBufferStrategy

List of usage examples for javax.swing JFrame createBufferStrategy

Introduction

In this page you can find the example usage for javax.swing JFrame createBufferStrategy.

Prototype

public void createBufferStrategy(int numBuffers) 

Source Link

Document

Creates a new strategy for multi-buffering on this component.

Usage

From source file:Filter3dTest.java

/**
 * Enters full screen mode and changes the display mode. If the specified
 * display mode is null or not compatible with this device, or if the
 * display mode cannot be changed on this system, the current display mode
 * is used./*w  w w. j ava 2 s.  c  om*/
 * <p>
 * The display uses a BufferStrategy with 2 buffers.
 */
public void setFullScreen(DisplayMode displayMode) {
    final JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setUndecorated(true);
    frame.setIgnoreRepaint(true);
    frame.setResizable(false);

    device.setFullScreenWindow(frame);

    if (displayMode != null && device.isDisplayChangeSupported()) {
        try {
            device.setDisplayMode(displayMode);
        } catch (IllegalArgumentException ex) {
        }
        // fix for mac os x
        frame.setSize(displayMode.getWidth(), displayMode.getHeight());
    }
    // avoid potential deadlock in 1.4.1_02
    try {
        EventQueue.invokeAndWait(new Runnable() {
            public void run() {
                frame.createBufferStrategy(2);
            }
        });
    } catch (InterruptedException ex) {
        // ignore
    } catch (InvocationTargetException ex) {
        // ignore
    }

}