Java多个屏幕

来源:互联网 发布:prezi中文版下载 mac 编辑:程序博客网 时间:2024/05/18 16:14

以下代码示例演示了如何在 GraphicsEnvironment 中针对每个屏幕设备的每个 GraphicsConfiguration 创建JFrame 对象。

   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++) {         JFrame f = new         JFrame(gs[j].getDefaultConfiguration());         Canvas c = new Canvas(gc[i]);          Rectangle gcBounds = gc[i].getBounds();         int xoffs = gcBounds.x;         int yoffs = gcBounds.y;           f.getContentPane().add(c);           f.setLocation((i*50)+xoffs, (i*60)+yoffs);         f.show();      }   }
原创粉丝点击