Java examples for JavaFX:Stage
Move JavaFX stage to center
//package com.java2s; import javafx.stage.Screen; import javafx.stage.Stage; public class Main { /**/*w ww .j a v a2 s . com*/ * Move stage to center * @param stage */ public static void centerStage(Stage stage) { double width = stage.getWidth(); double height = stage.getHeight(); stage.setX((Screen.getPrimary().getBounds().getWidth() - width) / 2); stage.setY((Screen.getPrimary().getBounds().getHeight() - height) / 2); } }