The java.awt.Toolkit acts as a bridge between the OS and Java, centralizing all OS-dependant graphics operations, so that in the same runtime environment may coexist different implementations of the OS/Java boundary. The Toolkit class itself is abstract - the concrete descendents handle the implementation details. We can get the current Toolkit implementation using the getDefaultToolkit() static method
One of the method defined in the class is the getScreenSize() method, that allows us to retrieve the screen size.
import java.awt.Toolkit; import java.awt.Dimension; public class Dimensiones { public static void main(String[] args) { Toolkit tk = Toolkit.getDefaultToolkit(); Dimension tama?o = tk.getScreenSize(); System.out.println("La pantalla es de " + tama?o.getWidth() + " x " + tama?o.getHeight() ); } }