java examples
Home Java Examples Resources Java Interview Questions
Brainpower SEO

How to get my screen size?

package com.javacoderanch.example.java.awt;

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

public class ScreenSizeExample {
    public static void main(String[] args)
    {
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        
        System.out.println("Screen Widht: " + screenSize.getWidth());
        System.out.println("Screen Height: " + screenSize.getHeight());
    }
}