get Default Graphics Device - Java 2D Graphics

Java examples for 2D Graphics:GraphicsDevice

Description

get Default Graphics Device

Demo Code


//package com.java2s;
import java.awt.DisplayMode;
import java.awt.Frame;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;

public class Main {
    public static GraphicsDevice getDefaultGraphicsDevice(Frame frame,
            int bitDepth, int frequency) {
        DisplayMode displayMode = new DisplayMode(frame.getWidth(),
                frame.getHeight(), bitDepth, frequency);
        GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment
                .getLocalGraphicsEnvironment();
        GraphicsDevice graphicsDevice = graphicsEnvironment
                .getDefaultScreenDevice();
        graphicsDevice.setFullScreenWindow(frame);
        graphicsDevice.setDisplayMode(displayMode);
        return graphicsDevice;
    }/* ww  w .ja va 2s.c  om*/
}

Related Tutorials