Example usage for java.awt GraphicsEnvironment getLocalGraphicsEnvironment

List of usage examples for java.awt GraphicsEnvironment getLocalGraphicsEnvironment

Introduction

In this page you can find the example usage for java.awt GraphicsEnvironment getLocalGraphicsEnvironment.

Prototype

public static GraphicsEnvironment getLocalGraphicsEnvironment() 

Source Link

Document

Returns the local GraphicsEnvironment .

Usage

From source file:ShowConfigurations.java

public static void main(String[] args) {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice defaultScreen = ge.getDefaultScreenDevice();
    GraphicsConfiguration[] configurations = defaultScreen.getConfigurations();
    System.out.println("Default screen device: " + defaultScreen.getIDstring());
    for (int i = 0; i < configurations.length; i++) {
        System.out.println("  Configuration " + (i + 1));
        System.out.println("  " + configurations[i].getColorModel());
    }/*from  ww w.  ja v a  2  s.  c o m*/
    System.exit(0);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    try {//from   w  w w .j  a  va  2s . co m
        GraphicsDevice[] gs = ge.getScreenDevices();

        int numScreens = gs.length;
    } catch (HeadlessException e) {

    }
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gs = ge.getScreenDevices();

    for (int i = 0; i < gs.length; i++) {
        DisplayMode dm = gs[i].getDisplayMode();

        int refreshRate = dm.getRefreshRate();
        if (refreshRate == DisplayMode.REFRESH_RATE_UNKNOWN) {
            System.out.println("Unknown rate");
        }//from  w ww  .jav  a  2 s  . co m

        int bitDepth = dm.getBitDepth();
        int numColors = (int) Math.pow(2, bitDepth);
    }
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gs = ge.getDefaultScreenDevice();

    boolean canChg = gs.isDisplayChangeSupported();
    if (canChg) {
        DisplayMode displayMode = gs.getDisplayMode();
        int screenWidth = 640;
        int screenHeight = 480;
        int bitDepth = 8;
        displayMode = new DisplayMode(screenWidth, screenHeight, bitDepth, displayMode.getRefreshRate());
        try {//from   w ww . j av a  2  s.c o  m
            gs.setDisplayMode(displayMode);
        } catch (Throwable e) {
            gs.setFullScreenWindow(null);
        }
    }
}

From source file:Main.java

public static void main(String[] argv) {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gs = ge.getDefaultScreenDevice();
    GraphicsConfiguration gc = gs.getDefaultConfiguration();
    System.out.println(gc.getColorModel(Transparency.BITMASK));
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gs = ge.getScreenDevices();
    for (int i = 0; i < gs.length; i++) {
        VolatileImage im = gs[i].getDefaultConfiguration().createCompatibleVolatileImage(1, 1);
        int bytes = gs[i].getAvailableAcceleratedMemory();
        if (bytes < 0) {
            System.out.println("Amount of memory is unlimited");
        }//ww w. j ava  2s. c  o  m

        im.flush();
    }
}

From source file:Main.java

public static void main(String[] args) {
    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice vc = env.getDefaultScreenDevice();
    JFrame window = new JFrame();
    JPanel comp = new JPanel();
    comp.setBackground(Color.RED);
    window.add(comp);/*from w  w  w .  ja  va 2s . c  o  m*/
    window.setUndecorated(true);
    window.setResizable(false);
    vc.setFullScreenWindow(window);
}

From source file:CenteringaWindow.java

public static void main(String[] args) {
    JFrame aWindow = new JFrame("This is the Window Title");
    Point center = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint();
    int windowWidth = 400;
    int windowHeight = 150;
    // set position and size
    aWindow.setBounds(center.x - windowWidth / 2, center.y - windowHeight / 2, windowWidth, windowHeight);
    aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    aWindow.setVisible(true); // Display the window
}

From source file:Main.java

public static void main(String[] args) {
    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    Rectangle bounds = env.getMaximumWindowBounds();
    System.out.println("Screen Bounds: " + bounds);

    GraphicsDevice screen = env.getDefaultScreenDevice();
    GraphicsConfiguration config = screen.getDefaultConfiguration();
    System.out.println("Screen Size  : " + config.getBounds());

    JFrame frame = new JFrame("Frame Info");
    System.out.println("Frame Insets : " + frame.getInsets());

    frame.setSize(200, 200);/*from  w  w w  .ja v  a 2 s  .  com*/
    System.out.println("Frame Insets : " + frame.getInsets());
    frame.setVisible(true);

    System.out.println("Frame Size   : " + frame.getSize());
    System.out.println("Frame Insets : " + frame.getInsets());
    System.out.println("Content Size : " + frame.getContentPane().getSize());
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gs = ge.getDefaultScreenDevice();
    GraphicsConfiguration gc = gs.getDefaultConfiguration();

    BufferedImage bimage = gc.createCompatibleImage(100, 100, Transparency.TRANSLUCENT);
}