|
8 | 8 | import javafx.event.Event; |
9 | 9 | import javafx.event.EventHandler; |
10 | 10 | import javafx.fxml.FXMLLoader; |
| 11 | +import javafx.geometry.Rectangle2D; |
11 | 12 | import javafx.scene.Parent; |
12 | 13 | import javafx.scene.Scene; |
13 | 14 | import javafx.scene.control.Button; |
|
23 | 24 | import javafx.scene.input.MouseButton; |
24 | 25 | import javafx.scene.input.MouseEvent; |
25 | 26 | import javafx.stage.Modality; |
| 27 | +import javafx.stage.Screen; |
26 | 28 | import javafx.stage.Stage; |
27 | 29 | import javafx.stage.WindowEvent; |
28 | 30 | import javafx.util.Callback; |
@@ -83,6 +85,11 @@ public static Scene getJFXDecoratorScene(JFXDecorator decorator) { |
83 | 85 | Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
84 | 86 | double width = screenSize.width / 1.35; |
85 | 87 | double height = screenSize.height / 1.2; |
| 88 | + Rectangle2D bounds = Screen.getPrimary().getVisualBounds(); |
| 89 | + if (width > bounds.getWidth() || height > bounds.getHeight()) {//解决屏幕缩放问题 |
| 90 | + width = bounds.getWidth(); |
| 91 | + height = bounds.getHeight(); |
| 92 | + } |
86 | 93 | Scene scene = new Scene(decorator, width, height); |
87 | 94 | final ObservableList<String> stylesheets = scene.getStylesheets(); |
88 | 95 | stylesheets.addAll( |
|
0 commit comments