📜  java windowbuilder 多监视器窗口模式 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:43.196000             🧑  作者: Mango

代码示例1
public Main() {

    JFrame testingBlack = new JFrame("MCVe");

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    GraphicsConfiguration gc = gds[1].getDefaultConfiguration();
    Rectangle rect = gc.getBounds();
    testingBlack.setLocation(rect.getLocation());

    // or, if you like this style better

    testingBlack.setLocation(GraphicsEnvironment
                             .getLocalGraphicsEnvironment()
                             .getScreenDevices()[1]
                             .getDefaultConfiguration()
                             .getBounds()
                             .getLocation());

    testingBlack.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    testingBlack.setVisible(true);
}