多屏幕 站点:爱心种子小博士 关键字:多屏幕
|
多屏幕 import java.awt.*;
import java.awt.event.*;
public class MultipleScreenDemo{
public static void main(String args[]){
GraphicsEnvironment ge;
ge=GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gdArray=ge.getScreenDevices();
System.out.println(gdArray.length+" ");
for(int i=0;i<gdArray.length;i++){
GraphicsDevice gd=gdArray[i];
GraphicsConfiguration gcArray[]=gd.getConfigurations();
System.out.println(gcArray.length+" ");
for(int j=0;j<gcArray.length;j++){
Frame f=new Frame(gdArray[i].getDefaultConfiguration());
Rectangle bounds=gcArray[j].getBounds();
int xoffset=bounds.x;
int yoffset=bounds.y;
f.addWindowListener(new wClose());
f.setTitle("Screen"+Integer.toString(i)+",GC#"+
Integer.toString(j));
f.setSize(200,200);
f.setLocation((j*50)+xoffset,(j*60)+yoffset);
f.setVisible(true);
}
}
}
}
class wClose extends WindowAdapter{
public void windowClosing(WindowEvent e){
System.exit(0);
}
}
|
|
|
|