Java open new windows at the second monitor in full screen size without toolbar

GraphicsConfiguration config = this.getGraphicsConfiguration();
GraphicsDevice myScreen = config.getDevice();
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gs = ge.getScreenDevices();
for (int i = 0; i < gs.length; i++) {
// System.out.println(“id is ” + gs[i].getIDstring() + ” and the current id is ” + myScreen);
// System.out.println(gs[i].getDisplayMode().getWidth() + ” ” + gs[i].getDisplayMode().getHeight());

if (!gs[i].equals(myScreen)) {
// System.out.println(“i = ” + i);
this.setLocation(gs[i].getDefaultConfiguration().getBounds().x, this.getY());
this.setExtendedState(JFrame.MAXIMIZED_BOTH);
this.setUndecorated(true);
}

//System.out.println(java.awt.Toolkit.getDefaultToolkit().getScreenSize());
// to check default resolution of the device
}

Leave a Reply