JavaFX全屏

//舞台最大化
primaryStage.setMaximized(true);
//获取窗口标题栏之外的最大尺寸
Screen screen = Screen.getPrimary();
Rectangle2D bounds = screen.getVisualBounds();
//再减去Windows任务栏尺寸
Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration());
//设置舞台,假设舞台内顶级父容器为Pane
Pane pane = new Pane();
primaryStage.setScene(new Scene(pane));
primaryStage.setTitle("全屏体验");
pane.setPrefWidth(bounds.getMaxX() - insets.left - insets.right);
pane.setPrefHeight(bounds.getMaxY() - insets.bottom - insets.top);

 

你可能感兴趣的:(Java,#,JavaFX)