Here you can find the source of getOppositeFullScreenBoundsFor(Rectangle r, boolean includeReservedInsets)
Parameter | Description |
---|---|
r | the original rectangle |
includeReservedInsets | if taskbar and other windowing insets should be included in the returned area |
public static Rectangle getOppositeFullScreenBoundsFor(Rectangle r, boolean includeReservedInsets)
//package com.java2s; /******************************************************************************* * Copyright (c) 2010 BSI Business Systems Integration AG. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/* w w w . ja v a 2s. c o m*/ * BSI Business Systems Integration AG - initial API and implementation ******************************************************************************/ import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.Rectangle; import java.util.TreeMap; public class Main { /** * @param r * the original rectangle * @param includeReservedInsets * if taskbar and other windowing insets should be included in the * returned area * @return iff there are multiple monitors the other monitor than the * effective view of the monitor that the rectangle mostly coveres, or * null if there is just one screen */ public static Rectangle getOppositeFullScreenBoundsFor(Rectangle r, boolean includeReservedInsets) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); TreeMap<Integer, Rectangle> prioMap = new TreeMap<Integer, Rectangle>(); for (GraphicsDevice dev : ge.getScreenDevices()) { Rectangle bounds; if ((!includeReservedInsets) && dev == ge.getDefaultScreenDevice()) { bounds = ge.getMaximumWindowBounds(); } else { bounds = dev.getDefaultConfiguration().getBounds(); } Rectangle intersection = bounds.intersection(r); prioMap.put(intersection.width * intersection.height, bounds); } if (prioMap.size() <= 1) { return null; } else { return prioMap.get(prioMap.firstKey()); } } }