20
May

Screen dimensions in java

Following code snippet can be used to capture screen size in java:

import java.awt.Dimension;
import java.awt.Toolkit;

public class ClassFileInstaller {
public static void main(String[] args) {

Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int screenHeight = screenSize.height;
int screenWidth = screenSize.width;

System.out.println(screenHeight);
System.out.println(screenWidth);

}
}