Java by API/java.awt/GraphicsConfiguration
GraphicsConfiguration: createCompatibleImage(int width, int height, int transparency)
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Transparency;
import java.awt.image.BufferedImage;
public class Main {
public static void main(String[] argv) throws Exception {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gs = ge.getDefaultScreenDevice();
GraphicsConfiguration gc = gs.getDefaultConfiguration();
// Create an image that does not support transparency
BufferedImage bimage = gc.createCompatibleImage(100, 100, Transparency.OPAQUE);
}
}
GraphicsConfiguration: getBounds()
import java.awt.Dimension;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Point;
import java.awt.Rectangle;
public class MainClass {
public static void main(String[] args) {
GraphicsEnvironment ge;
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);
}
}
GraphicsConfiguration: getColorModel()
/*
Default screen device: \Display0
Configuration 1
DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0
Configuration 2
DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0
Configuration 3
DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0
Configuration 4
DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0
Configuration 5
DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0
Configuration 6
DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0*/
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
public class MainClass {
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());
}
}
}