This Java tip illustrates a method of getting the size of the screen. The developer may use getScreenSize() to get the size of the default screen.

 // Current size of the default screen
    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();

Further, in case one or more screens are present, the developer may get the size of the screen by using a for loop as illustrated below.

  GraphicsEnvironment environment = 
    GraphicsDevice[] devices = environment.getScreenDevices();
    // Get size of each screen
    for (int i=0; i<devices.length; i++) {
        DisplayMode dmode = devices[i].getDisplayMode();
        int screenWidth = dmode.getWidth();
        int screenHeight = dmode.getHeight();