Java Screen Size getMaxUsableScreenSize()

Here you can find the source of getMaxUsableScreenSize()

Description

get Max Usable Screen Size

License

Apache License

Declaration

public static Dimension getMaxUsableScreenSize() 

Method Source Code

//package com.java2s;
/*//from w  w w.ja v a2s  . c  o m
 * Copyright 2004-2010 Information & Software Engineering Group (188/1)
 *                     Institute of Software Technology and Interactive Systems
 *                     Vienna University of Technology, Austria
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.ifs.tuwien.ac.at/dm/somtoolbox/license.html
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.awt.Dimension;

import java.awt.GraphicsEnvironment;

import java.awt.Toolkit;

public class Main {
    public static Dimension getMaxUsableScreenSize() {
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        // we don't directly use the width from the Toolkit, as on multi-screen twin displays, it gives the total
        // width of all displays
        // thus, we take the smaller value of the toolkit's and the graphics environment
        // we don't take the graphics environment directly, as that gives the total, and not just the usable width
        // i.e. it doesn't take a left/right (i.e. vertical) toolbar into account
        // thus, this approach should work fine on single-display screens with a vertical toolbar,
        // as well as on multi-screen displays w/o such a vertical toolbar
        // it will most probably not work well on multi-screen displays with a vertical toolbar, as the frame will
        // be too wide
        screenSize.width = Math.min(screenSize.width, GraphicsEnvironment
                .getLocalGraphicsEnvironment().getDefaultScreenDevice()
                .getDisplayMode().getWidth());
        screenSize.height -= 48;
        return screenSize;
    }
}

Related

  1. getLocationFromMouse(Dimension panelPrefSize_)
  2. getMaximumWindowBounds()
  3. getMaximumWindowBounds()
  4. getMaximumWindowWidth()
  5. getMaxSize(Window frame)
  6. getMaxWindowSize()
  7. getMinimumCacheSize(int tileSize, double overdrawFactor)
  8. getSizeWithScreen(double xd, double yd)
  9. getSystemSizeRate()