From a4b863ef6d2aa8d6c55e4beb3ede2dfd6d821b63 Mon Sep 17 00:00:00 2001 From: vito Date: Wed, 20 Jun 2018 15:32:51 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-8721=20win=E4=B8=8B10.0=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E5=8A=A8=E7=94=BB=E4=BD=8D=E7=BD=AE=E6=9C=AA=E5=A4=84?= =?UTF-8?q?=E4=BA=8E=E5=B1=8F=E5=B9=95=E6=AD=A3=E4=B8=AD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/start/fx/SplashFxWindow.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/designer-realize/src/com/fr/start/fx/SplashFxWindow.java b/designer-realize/src/com/fr/start/fx/SplashFxWindow.java index e4d845d27..be7c70937 100644 --- a/designer-realize/src/com/fr/start/fx/SplashFxWindow.java +++ b/designer-realize/src/com/fr/start/fx/SplashFxWindow.java @@ -6,6 +6,7 @@ import com.fr.stable.OperatingSystem; import com.fr.start.SplashContext; import javafx.application.Application; import javafx.application.Platform; +import javafx.geometry.Rectangle2D; import javafx.scene.Scene; import javafx.scene.image.Image; import javafx.scene.image.ImageView; @@ -13,6 +14,7 @@ import javafx.scene.layout.AnchorPane; import javafx.scene.paint.Color; import javafx.scene.text.Font; import javafx.scene.text.Text; +import javafx.stage.Screen; import javafx.stage.Stage; import javafx.stage.StageStyle; @@ -110,8 +112,10 @@ public class SplashFxWindow extends Application { root.getChildren().add(moduleInfo); root.getChildren().add(thanks); - Scene scene = new Scene(root, WINDOW_WIDTH, WINDOW_HEIGHT, null); - primaryStage.setScene(scene); + primaryStage.setWidth(WINDOW_WIDTH); + primaryStage.setHeight(WINDOW_HEIGHT); + primaryStage.setScene(new Scene(root, WINDOW_WIDTH, WINDOW_HEIGHT, null)); + setWindowCenter(primaryStage); primaryStage.show(); } @@ -128,6 +132,17 @@ public class SplashFxWindow extends Application { }); } + /** + * 设置窗口居中 + * + * @param stage 窗口 + */ + private void setWindowCenter(Stage stage) { + Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds(); + stage.setX(primaryScreenBounds.getMinX() + (primaryScreenBounds.getWidth() - stage.getWidth()) / 2.0); + stage.setY(primaryScreenBounds.getMinY() + (primaryScreenBounds.getHeight() - stage.getHeight()) / 2.0); + } + /** * 更新模块信息 *