This example describes how to get screen size in Java. java.awt.Toolkit class can be used to get the screen sizes as follows.

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