guiscreens.java

来自「java swing 开发代码」· Java 代码 · 共 38 行

JAVA
38
字号
// GuiScreens.java// A quick utility to print out graphic device information.  Will work on// systems with multiple monitors.//package	jswing.ch03;import java.awt.*;import javax.swing.*;public class GuiScreens {  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);      }      System.out.println("Overall bounds: " + virtualBounds);    }  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?