JavaFX File chooser enables users to browse the files from the file system. javafx.stage.FileChooser class represents FileChooser. It can be created by instantiating FileChooser class. It contains two main methods.
As we see in the modern day applications, there are two types of dialogues shown to the user, one is for opening the file and the other is for saving the files. In each case, the user needs to browse a location for the file and give the name to the file.
The FileChooser class provides two types of methods,
The following code implements showSaveDialog() method.
The above code shows the following dialogue box to the user where user is prompted to browse the location of the file which needs to be opened.
The following code shows a Label, TextField and a Button to the user. An open file dialogue box will open on clicking the browse button.
The following code shows the dialogue box for saving the files.