📄 multimonitorexample2.java
字号:
package JFCBook.Chapter3.jdk13;
import java.awt.*;
import javax.swing.*;
public class MultiMonitorExample2 {
public static void main(String[] args) {
GraphicsEnvironment ge = GraphicsEnvironment.
getLocalGraphicsEnvironment();
GraphicsDevice[] gd = ge.getScreenDevices();
System.out.println("There are " + gd.length + " screen device(s)");
ImageIcon image = new ImageIcon(
MultiMonitorExample2.class.getResource("images/lem.jpg"));
for (int i = 0; i < gd.length; i++) {
GraphicsConfiguration[] gcs = gd[i].getConfigurations();
System.out.println("Device " + i + " has " + gcs.length +
" configuration(s)");
for (int j = 0; j < gcs.length; j++) {
System.out.println("\tConfig " + j + " bounds: " +
gcs[j].getBounds());
}
JFrame f = new JFrame("Screen " + i);
JLabel l = new JLabel(image);
f.getContentPane().add(l);
f.pack();
GraphicsConfiguration gc = gd[i].getDefaultConfiguration();
Rectangle pt = gc.getBounds();
f.setLocation(pt.x + 100, pt.y + 100);
f.setVisible(true);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -