Java tutorial
//package com.java2s; //License from project: Apache License import java.awt.GraphicsEnvironment; import java.awt.Rectangle; import java.awt.Window; public class Main { public static Rectangle getScreenSize(Window win) { Rectangle sb; if (win == null) { sb = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice() .getDefaultConfiguration().getBounds(); } else { sb = win.getGraphicsConfiguration().getBounds(); } return sb; } }