Example usage for java.awt GraphicsDevice getBestConfiguration

List of usage examples for java.awt GraphicsDevice getBestConfiguration

Introduction

In this page you can find the example usage for java.awt GraphicsDevice getBestConfiguration.

Prototype

public GraphicsConfiguration getBestConfiguration(GraphicsConfigTemplate gct) 

Source Link

Document

Returns the "best" configuration possible that passes the criteria defined in the GraphicsConfigTemplate .

Usage

From source file:J3dSwingFrame.java

/**
 * Construct the test frame with a menubar and 3D canvas
 *//*from   ww w.ja  v  a 2  s.c om*/
public J3dSwingFrame() {
    super("Java3D Tester");

    // Disable lightweight menus
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);

    JMenuBar menubar = new JMenuBar();

    // File menu
    JMenu file_menu = new JMenu("File");
    menubar.add(file_menu);

    close_menu = new JMenuItem("Exit");
    close_menu.addActionListener(this);
    file_menu.add(close_menu);

    setJMenuBar(menubar);

    GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D();
    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice device = env.getDefaultScreenDevice();
    GraphicsConfiguration config = device.getBestConfiguration(template);

    canvas = new Canvas3D(config);

    // add the canvas to this frame. Since this is the only thing added to
    // the main frame we don't care about layout managers etc.

    getContentPane().add(canvas, "Center");

    constructWorld();

    setSize(600, 600);
}