Get screen size and resolution, with java.awt.Toolkit

Java example to get screen size and resolution, with java.awt.Toolkit:

package javagetscreensize;

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

/**
*
* @web http://java-buddy.blogspot.com/
*/
public class JavaGetScreenSize {

public static void main(String[] args) {
Toolkit myToolkit = Toolkit.getDefaultToolkit();
Dimension screenSize = myToolkit.getScreenSize();
int screenResolution = myToolkit.getScreenResolution();
System.out.println("Screen size = " + screenSize.width + " x " + screenSize.height);
System.out.println("Screen Resolution: " + screenResolution + " dots-per-inch");
}

}


Source: http://java-buddy.blogspot.com/

Be the first to comment

Leave a Reply

Your email address will not be published.


*