Java Toolkit.getScreenSize()
Syntax
Toolkit.getScreenSize() has the following syntax.
public abstract Dimension getScreenSize() throws HeadlessException
Example
In the following code shows how to use Toolkit.getScreenSize() method.
import java.awt.Dimension;
import java.awt.Toolkit;
/*from w w w . jav a 2s . c o m*/
public class Main {
public static void main(String[] args) {
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension d = tk.getScreenSize();
System.out.println("Screen width = " + d.width);
System.out.println("Screen height = " + d.height);
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.awt »
Java Tutorial »
java.awt »