Example usage for java.awt GraphicsDevice getConfigurations

List of usage examples for java.awt GraphicsDevice getConfigurations

Introduction

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

Prototype

public abstract GraphicsConfiguration[] getConfigurations();

Source Link

Document

Returns all of the GraphicsConfiguration objects associated with this GraphicsDevice .

Usage

From source file:Main.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   w  w w. ja  va  2s.  c  o  m*/
}

From source file:Main.java

public static void main(String[] args) {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();

    Rectangle vBounds = new Rectangle();

    GraphicsDevice[] gdArray = ge.getScreenDevices();

    for (int i = 0; i < gdArray.length; i++) {
        GraphicsDevice gd = gdArray[i];

        GraphicsConfiguration[] gcArray = gd.getConfigurations();

        for (int j = 0; j < gcArray.length; j++)
            vBounds = vBounds.union(gcArray[j].getBounds());
    }//w ww .  j  av  a  2 s .c o m

    Point origin = vBounds.getLocation();
    System.out.println("Virtual x = " + origin.x);
    System.out.println("Virtual y = " + origin.y);

    Dimension size = vBounds.getSize();
    System.out.println("Virtual width = " + size.width);
    System.out.println("Virtual height = " + size.height);
}

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 w w w.ja va2 s  .c  o  m*/
    System.exit(0);
}

From source file:MainClass.java

public static void main(String[] args) {
    GraphicsEnvironment ge;/*w  w  w .j a va  2 s . c  o m*/
    ge = GraphicsEnvironment.getLocalGraphicsEnvironment();

    Rectangle vBounds = new Rectangle();

    GraphicsDevice[] gdArray = ge.getScreenDevices();

    for (int i = 0; i < gdArray.length; i++) {
        GraphicsDevice gd = gdArray[i];

        GraphicsConfiguration[] gcArray = gd.getConfigurations();

        for (int j = 0; j < gcArray.length; j++)
            vBounds = vBounds.union(gcArray[j].getBounds());
    }

    Point origin = vBounds.getLocation();
    System.out.println("Virtual x = " + origin.x);
    System.out.println("Virtual y = " + origin.y);

    Dimension size = vBounds.getSize();
    System.out.println("Virtual width = " + size.width);
    System.out.println("Virtual height = " + size.height);
}

From source file:Main.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));
        GraphicsConfiguration c = configurations[i];
        System.out.println("  " + c.getColorModel());
        System.out.println("  " + c.getBounds());
        System.out.println("  " + c.getBufferCapabilities());
        System.out.println("  " + c.getDefaultTransform());
        System.out.println("  " + c.getDevice());
    }/* w ww  . j a v a 2s .co  m*/
}

From source file:Main.java

public static void main(String[] args) {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gs = ge.getScreenDevices();
    for (int j = 0; j < gs.length; j++) {
        GraphicsDevice gd = gs[j];
        System.out.println("Device " + j + ": " + gd);
        GraphicsConfiguration[] gc = gd.getConfigurations();
        for (int i = 0; i < gc.length; i++) {
            System.out.println(gc[i]);
            System.out.println(gc[i].getBounds());
        }/*from  w ww. j a va  2  s .c om*/
    }
}

From source file:GuiScreens.java

public static void main(String[] args) {
    Rectangle virtualBounds = new Rectangle();
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gs = ge.getScreenDevices();
    JFrame frame[][] = new JFrame[gs.length][];
    for (int j = 0; j < gs.length; j++) {
        GraphicsDevice gd = gs[j];
        System.out.println("Device " + j + ": " + gd);
        GraphicsConfiguration[] gc = gd.getConfigurations();
        frame[j] = new JFrame[gc.length];

        for (int i = 0; i < gc.length; i++) {
            System.out.println("  Configuration " + i + ": " + gc[i]);
            System.out.println("    Bounds: " + gc[i].getBounds());
            virtualBounds = virtualBounds.union(gc[i].getBounds());
            frame[j][i] = new JFrame("Config: " + i, gc[i]);
            frame[j][i].setBounds(50, 50, 400, 100);
            frame[j][i].setLocation((int) gc[i].getBounds().getX() + 50, (int) gc[i].getBounds().getY() + 50);
            frame[j][i].getContentPane().add(new JTextArea("Config:\n" + gc[i]));
            frame[j][i].setVisible(true);
        }/*from  w w  w.  j a va2s.co  m*/
        System.out.println("Overall bounds: " + virtualBounds);
    }
}

From source file:Main.java

/**
 * returns the virtual screensize in a multimonitor system
 * /* w ww.ja  v a2s. c om*/
 * @return
 */
public static Dimension getVirtualScreenSize() {
    Rectangle virtualBounds = new Rectangle();
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gs = ge.getScreenDevices();
    for (int j = 0; j < gs.length; j++) {
        GraphicsDevice gd = gs[j];
        GraphicsConfiguration[] gc = gd.getConfigurations();
        for (int i = 0; i < gc.length; i++) {
            virtualBounds = virtualBounds.union(gc[i].getBounds());
        }
    }
    return virtualBounds.getSize();
}

From source file:Main.java

public static GraphicsConfiguration getGraphicsConfigurationForCurrentLocation(Window window) {
    GraphicsConfiguration ownedConfig = window.getGraphicsConfiguration();
    Point currLocation = window.getLocation();
    // Shortcut for "owned" case
    if (ownedConfig.getBounds().contains(currLocation))
        return ownedConfig;

    // Search for the right screen
    GraphicsDevice[] screens = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
    for (GraphicsDevice screen : screens)
        for (GraphicsConfiguration config : screen.getConfigurations())
            if (config.getBounds().contains(currLocation))
                return config;

    // If none found, lets return the "owned" one
    return ownedConfig;
}

From source file:Main.java

/**
 * Returns the position of the screen containing the argument window or the primary screen if current window is not
 * selected./* w w  w  .j a  v a 2 s.com*/
 * 
 * @param window The window.
 * @return The location point.
 */
public static Point getScreenPosition(Window window) {
    GraphicsDevice graphicsDevice = getGraphicsDevice(window);
    GraphicsConfiguration[] configurations = graphicsDevice.getConfigurations();
    return configurations[0].getBounds().getLocation();
}