How do you get the screen width in java?

前端 未结 12 690
说谎
说谎 2020-12-13 08:52

Does anyone know how you would get the screen width in java? I read something about some toolkit method but I\'m not quite sure what that is.

Thanks, Andrew

12条回答
  •  甜味超标
    2020-12-13 09:31

    The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars.

    If what you want is the "working area" of the screen, use this:

    public static int GetScreenWorkingWidth() {
        return java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().width;
    }
    
    public static int GetScreenWorkingHeight() {
        return java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().height;
    }
    

提交回复
热议问题