Java Screen Size setWindowDesktopSize(Window window, double sizeX, double sizeY)

Here you can find the source of setWindowDesktopSize(Window window, double sizeX, double sizeY)

Description

set Window Desktop Size

License

Open Source License

Declaration

public static void setWindowDesktopSize(Window window, double sizeX, double sizeY) 

Method Source Code

//package com.java2s;
/* /*from   w  w  w.j  a v a 2 s .com*/
 * The MIT License
 *
 * Copyright 2014 Kamnev Georgiy (nt.gocha@gmail.com).
 *
 * ??????? ????????? ?????????, ????????????, ?????, ?????????? ????? ??????? ???????????? 
 * ????????????? ? ??????????????? ???????????? (? ?????????? ?????????? "??????????? ????????????"), 
 * ????????????? ??????????? ???????????? ??? ???????????, ???????? ?????????????? ????? ?? 
 * ??????????????, ???????????, ?????????, ???????????, ??????????, ?????????????????, ?????????????????? 
 * ?/??? ??????? ????? ???????????? ?????????????, ????? ??? ? ?????, ??????? ??????????????????? 
 * ?????? ??????????? ????????????, ??? ??????????? ?????????? ????????:
 *
 * ??????????????? ???????? ? ?????? ????????? ?????? ???? ???????? ?? ???? ????? 
 * ??? ???????? ?????? ??????? ???????????? ?????????????.
 *
 * ????????? ????????????? ???????????? ???????????????? ????? ?????, ??? ?????? ????? ???????????, 
 * ????? ????????????? ??? ?????????????????, ????????, ??? ??? ???????????????? ????????????? ?????????? ????????????, 
 * ???????????? ?? ??? ????????????? ??????????????? ? ??????????????? ?????. ??? ? ?????? ??????? ??????? 
 * ??? ?????????????????? ??? ?????? ????????????????? ?? ?????? ? ??????????? ???????, ??????? 
 * ??? ?????? ???????????? ?? ??????????? ?????????????, ????????? ??? ??????, ?????????? ??, ??????? 
 * ????????? ??? ???????????? ? ????????????? ????????????? ??? ???????????????? ?????????????? ???????????? 
 * ??? ?????? ?????????? ? ????????????? ?????????????.
 */

import java.awt.GraphicsEnvironment;

import java.awt.Window;

public class Main {

    public static void setWindowDesktopSize(Window window, double sizeX, double sizeY) {
        if (window == null) {
            throw new IllegalArgumentException("window == null");
        }
        if (sizeX < 0 || sizeX > 1)
            throw new IllegalArgumentException("size<0 | size>1");
        if (sizeY < 0 || sizeY > 1)
            throw new IllegalArgumentException("size<0 | size>1");

        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        int screenX = ge.getCenterPoint().x * 2;
        int screenY = ge.getCenterPoint().y * 2;

        window.setSize((int) ((double) screenX * sizeX), (int) ((double) screenY * sizeY));
    }
}

Related

  1. maximizeWindowWithMargin(final Window window, final int margin, final Dimension maxSize)
  2. screenSize()
  3. setLocationRelativeToAndSizeToWindow(Component parent, Component child, Dimension max)
  4. setSize(final Window window, final int minusX, final int minusY)
  5. setSize(Window window, double widthFactor, double heightFactor)
  6. setWindowSize(final Window w, final Rectangle r)
  7. sizeForScreen(Component component)