A quick utility to print out graphic device information : Graphic Environment « 2D Graphics GUI « Java

A quick utility to print out graphic device information

A quick utility to print out graphic device information
Java Swing, 2nd Edition
By Marc Loy, Robert Eckstein, Dave Wood, James Elliott, Brian Cole
ISBN: 0-596-00408-7
Publisher: O'Reilly 
// GuiScreens.java
//A quick utility to print out graphic device information. Will work on
//systems with multiple monitors.

import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;

import javax.swing.JFrame;
import javax.swing.JTextArea;

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);


Related examples in the same category

1.List all available fonts in the systemList all available fonts in the system
2.Show all fonts you have in your systemShow all fonts you have in your system
3.Determine if full-screen mode is supported directly
4.Leave full-screen mode (Return to normal windowed mode)
5.Enter full screen mode
6.Getting Screen Sizes
7.Getting Refresh Rates
8.Getting Number of Colors
9.Getting the Current Screen Refresh Rate and Number of Colors
10.Listing All Available Font Families
11.Getting the Font Faces for a Font Family
12.Create buffered images that are compatible with the screen
13.Create an image that does not support transparency from GraphicsConfiguration
14.Create an image that supports transparent pixels from GraphicsConfiguration
15.Getting Amount of Free Accelerated Image Memory
16.Get the available font family names
17.Get the available font names
18.Retrieve and print the graphic device information
19.Create an image that supports arbitrary levels of transparency from GraphicsConfiguration
20.Setting the Screen Size, Refresh Rate, or Number of Colors
21.If more than one screen is available, gets the size of each screen
22.Getting the Number of Screens
23.Get the GraphicsEnvironment and GraphicsDeviceGet the GraphicsEnvironment and GraphicsDevice
24.extends JComponent to exercise Graphics