Jen*_*gsa 19 java javafx windows-7-x64 javafx-8
这个小型JavaFX测试应用程序
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
public class ApplicationWithNonResizableStage extends Application {
public static void main(final String[] args) {
launch(args);
}
@Override
public void start(final Stage primaryStage) throws Exception {
final Rectangle rectangle = new Rectangle(200, 100, Color.POWDERBLUE);
final BorderPane pane = new BorderPane(rectangle);
final Scene scene = new Scene(pane);
primaryStage.setScene(scene);
primaryStage.setResizable(false);
primaryStage.show();
}
}
Run Code Online (Sandbox Code Playgroud)
产生一个不需要的填充窗口:

删除呼叫primaryStage.setResizable(false)也会删除效果:

出了什么问题?
kle*_*tra 43
正如已经评论过的,这种不同的行为!/ resizable闻起来像一个bug(有人可能会考虑提交问题;-)
较短(比手动调整大小)的方法是明确地将舞台适合场景:
primaryStage.setScene(scene);
primaryStage.setResizable(false);
primaryStage.sizeToScene();
Run Code Online (Sandbox Code Playgroud)
刚刚注意到这适用于jdk8,但不适用于jdk7.
为方便起见,更新了一个错误:jewelsea提交的原始报告作为(在新坐标中)的副本关闭了https://bugs.openjdk.java.net/browse/JDK-8089008 - 仍然打开,评论为win-只要.
| 归档时间: |
|
| 查看次数: |
15563 次 |
| 最近记录: |