get JavaFX Full Screen Stage - Java JavaFX

Java examples for JavaFX:Stage

Description

get JavaFX Full Screen Stage

Demo Code


//package com.java2s;

import javafx.geometry.Rectangle2D;

import javafx.stage.Screen;
import javafx.stage.Stage;

public class Main {
    public static Stage getFullScreenStage(String pTitle) {
        Screen screen = Screen.getPrimary();
        Rectangle2D bounds = screen.getVisualBounds();

        Stage stage = new Stage();
        stage.setTitle(pTitle);/*  w ww. j a va  2s .c  o m*/
        stage.setX(bounds.getMaxX() / 2);
        stage.setY(bounds.getMinY());
        stage.setWidth(bounds.getMaxX());
        stage.setHeight(bounds.getMaxY());

        return stage;
    }
}

Related Tutorials