这是功能。错误在stage.initStyle(StageStyle.UNDECORATED);表示在舞台可见后无法设置样式。你可以帮助我在这里我应该在函数中声明这个,并建议一些代码编辑,如果有的话。
@FXML
public void Showmain() {
// Handle Button event.
myButton3.setOnAction((e) -> {
System.out.println("Project screen");
// FXMLLoader fxmlLoader1= new FXMLLoader(getClass().getResource("Projectscreen.fxml"));
try {
Node node = (Node) e.getSource();
Stage stage = (Stage) node.getScene().getWindow();
//
scene = stage.getScene();
stage.setWidth(1280);
stage.setHeight(968);
stage.centerOnScreen();
stage.setTitle("Welcome to Kdaf");
// stage.initStyle(StageStyle.UNDECORATED);
//stage.setResizable(false);
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("Projectscreen.fxml"));
Parent root = (Parent) fxmlLoader.load();
scene.setRoot(root);
} catch (IOException exception) {
throw new RuntimeException(exception);
}
});
}