javafx.stage.FileChooser



如何在javafx gui应用程序中将javafx.stage. filechooser添加到场景中

我做了以下的

Group root = new Group(); 
Scene scene = new Scene(root,800,800,Color.BLANCHEDALMOND);
FileChooser fc = new FileChooser();
root.getChildren().add(fc);

但是我得到以下错误:

no suitable method found for add(javafx.stage.FileChooser)
    method java.util.List.add(int,javafx.scene.Node) is not applicable
      (actual and formal argument lists differ in length)
    method java.util.List.add(javafx.scene.Node) is not applicable
      (actual argument javafx.stage.FileChooser cannot be converted to javafx.scene.Node by method invocation conversion)
谁能给点提示?

FileChooser不是一个节点,所以你不能把它添加到组中。

使用:

fc.showOpenDialog(null);

fc.showSaveDialog(null);

参数为父窗口。如果我没记错的话,它可以是null

最新更新