Rectangle () { GraphicsDevice[] devices = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); if (devices.length == 0) { return new Rectangle(); } if (devices.length == 1) { return getScreenRectangle(devices[0]); } int minX = 0; int maxX = 0; int minY = 0; int maxY = 0; for (GraphicsDevice device : devices) { Rectangle rectangle = getScreenRectangle(device); int x = rectangle.x; if (minX > x) { minX = x; } x += rectangle.width; if (maxX < x) { maxX = x; } int y = rectangle.y; if (minY > y) { minY = y; } y += rectangle.height; if (maxY < y) { maxY = y; } } return new Rectangle(minX, minY, maxX - minX, maxY - minY); }