position on right most screen

This commit is contained in:
Patrick Haßel 2024-05-15 15:40:22 +02:00
parent 91e7d2541a
commit 510a3ec977

View File

@ -10,6 +10,7 @@ public class Window extends JFrame {
public Window() { public Window() {
add(new CircuitPanel()); add(new CircuitPanel());
positionOnRightMostScreen();
setDefaultCloseOperation(EXIT_ON_CLOSE); setDefaultCloseOperation(EXIT_ON_CLOSE);
setPreferredSize(new Dimension(1200, 900)); setPreferredSize(new Dimension(1200, 900));
setExtendedState(MAXIMIZED_BOTH); setExtendedState(MAXIMIZED_BOTH);
@ -17,6 +18,13 @@ public class Window extends JFrame {
setVisible(true); setVisible(true);
} }
private void positionOnRightMostScreen() {
final GraphicsDevice[] screens = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
final GraphicsDevice thirdScreen = screens[screens.length - 1];
final Rectangle screenBounds = thirdScreen.getDefaultConfiguration().getBounds();
setLocation(screenBounds.x, screenBounds.y);
}
public static void main(String[] args) { public static void main(String[] args) {
new Window(); new Window();
} }