Graphics Environments

SDK 1.4 recognizes a great deal of information about its environment. You can retrieve that information for your own code through the GraphicsEnvironment, GraphicsDevice, and GraphicsConfiguration classes from the java.awt package. While they aren’t part of Swing proper, these classes are definitely useful for Swing applications, especially those that take full advantage of their environment.
To sum up these classes, a system keeps a local GraphicsEnvironment object that describes the devices on the system with an array of GraphicsDevice objects. Each GraphicsDevice contains (or at least may contain) multiple configurations of device capabilities (such as pixel formats or which visual screen you’re on) bundled up in an array of GraphicsConfiguration objects.
If you’re curious about the various graphics configurations on your system, try out this little program, It prints information on all devices and configurations. For each configuration, it also pops up a JFrame using that configuration.

import java.awt.*;
import javax.swing.*;

public class GuiScreens {
	public static void main(String[] args) {
		Rectangle virtualBounds = new Rectangle();
		GraphicsEnvironment ge = GraphicsEnvironment
		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);
						new JTextArea("Config:n" + gc[i]));
			System.out.println("Overall bounds: " + virtualBounds);