18 lines
501 B
Java
18 lines
501 B
Java
package utilities;
|
|
|
|
import javafx.stage.Screen;
|
|
import javafx.stage.Stage;
|
|
|
|
public class FxUtilities {
|
|
public static void centerStage(Stage stage) {
|
|
double screenWidth = Screen.getPrimary().getVisualBounds().getWidth();
|
|
double screenHeight = Screen.getPrimary().getVisualBounds().getHeight();
|
|
|
|
double xPos = screenWidth / 2 - stage.getWidth() / 2;
|
|
double yPos = screenHeight / 2 - stage.getHeight() / 2;
|
|
|
|
stage.setX(xPos);
|
|
stage.setY(yPos);
|
|
}
|
|
}
|