Reputation: 21
How should I add javafx.stage.FileChooser to the scene in a javafx gui application.
I did the following
Group root = new Group();
Scene scene = new Scene(root,800,800,Color.BLANCHEDALMOND);
FileChooser fc = new FileChooser();
root.getChildren().add(fc);
However I get the following error.
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)
Could some one provide any tip?
Upvotes: 2
Views: 1115
Reputation: 197
FileChooser is not a node, so you cant add it to a group.
Use:
fc.showOpenDialog(null);
or
fc.showSaveDialog(null);
The parameter is the parent window. If I remember right, it can be null.
Upvotes: 2