Revisão | 244 (tree) |
---|---|
Hora | 2021-06-20 20:27:59 |
Autor | hirukawa_ryo |
* fx-util 0.4.4
Windows以外では start 直前にスプラッシュスクリーンを非表示にするようにしました。
macOS でステージ表示後にスプラッシュスクリーンが一瞬前面に出てきてしまう問題への対処のためです。
@@ -214,15 +214,24 @@ | ||
214 | 214 | public void start(Stage stage) throws Exception { |
215 | 215 | fxApplicationThread = Thread.currentThread(); |
216 | 216 | primaryStage = stage; |
217 | - stage.addEventHandler(WindowEvent.WINDOW_SHOWN, new EventHandler<WindowEvent>() { | |
218 | - @Override | |
219 | - public void handle(WindowEvent windowEvent) { | |
220 | - Platform.runLater(() -> { | |
221 | - closeSplashScreen(); | |
222 | - }); | |
223 | - primaryStage.removeEventHandler(windowEvent.getEventType(), this); | |
217 | + | |
218 | + boolean isWindows = System.getProperty("os.name", "").toLowerCase().startsWith("windows"); | |
219 | + if(isWindows) { | |
220 | + stage.addEventHandler(WindowEvent.WINDOW_SHOWN, new EventHandler<WindowEvent>() { | |
221 | + @Override | |
222 | + public void handle(WindowEvent windowEvent) { | |
223 | + Platform.runLater(() -> { | |
224 | + closeSplashScreen(); | |
225 | + }); | |
226 | + primaryStage.removeEventHandler(windowEvent.getEventType(), this); | |
227 | + } | |
228 | + }); | |
229 | + } else { | |
230 | + SplashScreen splash = SplashScreen.getSplashScreen(); | |
231 | + if(splash != null) { | |
232 | + splash.close(); | |
224 | 233 | } |
225 | - }); | |
234 | + } | |
226 | 235 | app.start(stage); |
227 | 236 | latch.countDown(); |
228 | 237 | } |