Java Graphics Settings getMaxWindowBounds(final GraphicsConfiguration gc, final boolean applyScreenInsets)

Here you can find the source of getMaxWindowBounds(final GraphicsConfiguration gc, final boolean applyScreenInsets)

Description

Returns maximum window bounds for the specified graphics configuration.

License

Open Source License

Parameter

Parameter Description
gc graphics configuration
applyScreenInsets whether or not should extract screen insets from max bounds

Return

maximum window bounds for the specified graphics configuration

Declaration

public static Rectangle getMaxWindowBounds(final GraphicsConfiguration gc, final boolean applyScreenInsets) 

Method Source Code

//package com.java2s;
/*/*from   w  w w.j  av  a  2  s.com*/
 * This file is part of WebLookAndFeel library.
 *
 * WebLookAndFeel library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * WebLookAndFeel library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with WebLookAndFeel library.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.awt.*;

public class Main {
    /**
     * Returns maximum window bounds for the specified graphics configuration.
     *
     * @param gc                graphics configuration
     * @param applyScreenInsets whether or not should extract screen insets from max bounds
     * @return maximum window bounds for the specified graphics configuration
     */
    public static Rectangle getMaxWindowBounds(final GraphicsConfiguration gc, final boolean applyScreenInsets) {
        if (gc != null) {
            // Note that we don't have to specify x/y offset of the screen here
            // It seems that maximized bounds require only bounds inside of the screen bounds, not bettween the screens overall
            final Rectangle b = gc.getBounds();
            if (applyScreenInsets) {
                // Taking screen insets into account
                final Insets si = Toolkit.getDefaultToolkit().getScreenInsets(gc);
                return new Rectangle(si.left, si.top, b.width - si.left - si.right, b.height - si.top - si.bottom);
            } else {
                // Using full screen
                return new Rectangle(0, 0, b.width, b.height);
            }
        } else {
            // Default GE bounds
            return GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
        }
    }
}

Related

  1. getDefaultConfig()
  2. getDefaultConfiguration()
  3. getDefaultGraphicsConfiguration()
  4. getDefaultGraphicsConfiguration()
  5. getDefaultGraphicsConfiguration()
  6. getRenderingHints(final Graphics2D g2d, final Map hintsToSave, Map savedHints)
  7. getRenderingHints(Graphics2D g2d, Map hintsToSave, RenderingHints savedHints)
  8. getRenderingHints(Graphics2D g2d, RenderingHints hintsToSave, RenderingHints savedHints)
  9. getSecondWindowConfiguration()