get JavaFX Screen Dimensions - Java JavaFX

Java examples for JavaFX:Rectangle

Description

get JavaFX Screen Dimensions

Demo Code


//package com.java2s;
import javafx.geometry.Rectangle2D;
import javafx.stage.Screen;
import java.util.HashMap;

public class Main {
    public static HashMap<String, Double> getScreenDimensions() {

        HashMap<String, Double> screenDimensions = new HashMap<>();

        Rectangle2D screenBounds = Screen.getPrimary().getVisualBounds();

        screenDimensions.put("width", screenBounds.getWidth());
        screenDimensions.put("height", screenBounds.getHeight());

        return screenDimensions;
    }/* w w  w.  j a va2 s.com*/
}

Related Tutorials