File tree Expand file tree Collapse file tree
src/main/java/com/xwintop/xJavaFxTool/utils Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package com .xwintop .xJavaFxTool .utils ;
22
33import com .xwintop .xJavaFxTool .utils .Config .Keys ;
4+ import javafx .geometry .Rectangle2D ;
5+ import javafx .stage .Screen ;
46import javafx .stage .Stage ;
57import lombok .extern .slf4j .Slf4j ;
68
9+ import java .util .List ;
10+
711/**
812 * @ClassName: StageUtils
913 * @Description: 更新场景工具类(解决点击任务栏图标无法最小化问题)
@@ -20,12 +24,21 @@ public static void loadPrimaryStageBound(Stage stage) {
2024 return ;
2125 }
2226
23- double left = Config .getDouble (Keys .MainWindowLeft , - 1 );
27+ double left = Config .getDouble (Keys .MainWindowLeft , stage . getX () );
2428 double top = Config .getDouble (Keys .MainWindowTop , -1 );
2529 double width = Config .getDouble (Keys .MainWindowWidth , -1 );
2630 double height = Config .getDouble (Keys .MainWindowHeight , -1 );
2731
28- if (left > 0 ) {
32+ List <Screen > list = Screen .getScreens ();
33+ double minX = 0 ;
34+ for (Screen screen : list ) {
35+ Rectangle2D screenRectangle2 = screen .getBounds ();
36+ if (screenRectangle2 .getMinX () < minX ) {
37+ minX = screenRectangle2 .getMinX ();
38+ }
39+ }
40+
41+ if (left > minX ) {
2942 stage .setX (left );
3043 }
3144 if (top > 0 ) {
You can’t perform that action at this time.
0 commit comments