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

...

// Get screen size in pixels, width by height.
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();

// Get screen resolution in dots per inch.
// The Americans who develop Java have not noticed the world has gone metric.
int dpi = Toolkit.getDefaultToolkit().getScreenResolution();