GraphicsEnvironment ge;
ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
for (GraphicsDevice gd : ge.getScreenDevices()) {
for (GraphicsConfiguration gc : gd.getConfigurations()) {
Rectangle gcBounds = gc.getBounds();
if (gcBounds.intersects(desired)) {
Rectangle inter = gcBounds.intersection(desired);
int size = inter.width * inter.height;
if (size > gcBestSize) {
gcBestSize = size;
int x2 = Math.max(gcBounds.x, Math.min(inter.x,