You can determine the screen resolution (screen size) using the Toolkit class. This method call returns the screen resolution in pixels, and stores the results in a Dimension object, as shown here:
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
You can then get the screen width and height as int's by directly accessing the width and height fields of the Dimension class, like this:
screenHeight = screenSize.height;
screenWidth = screenSize.width;
check this
another method