JavaFX File Chooser

The newest version of the JavaFX FileChooser uses native FileChoosers to allow the selection of files. This means that the FileChooser is guaranteed to pass Apple Store requirements on having the OS and not the app control file system operations. However, it also means that the look and feel of your app may clash with the look and feel of the JavaFX file chooser, thus providing a degraded user experience. Most would say that is a fair trade off, as customers will already be used to their OS’s file chooser, and custom a JavaFX file chooser might hurt the user experience.

This short JavaFX tutorial goes into the three most common FileChooser uses. They are:

  1. Choosing one file to open
  2. Choosing multiple files to open
  3. Saving to a file

We’ll go into all three uses with examples.

Continue reading “JavaFX File Chooser”

Open and Save Menus in JavaFX

I have already written a tutorial on JavaFX FileChoosers. However, the previous example did not integrate a JavaFX MenuBar or an FXML file into the mix. Typically, you don’t create or design FileChoosers in FXML, though some dialogs can be designed in FXML. However, FileChoosers tend to be created and shown programmatically, rather than in FXML for display later.

This JavaFX FileChooser example shows a basic MenuBar with Open, Save, SaveAs and Quit MenuItems as shown in the image below.

JavaFX FileChooser Menus
A simple JavaFX MenuBar with Open, Save, Save As and Quit MenuItems.

Continue reading “Open and Save Menus in JavaFX”