Thursday, January 7, 2016

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");
    }
    
}



No comments:

Post a Comment