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:
JavaFX is easy once you get the hang of it, but for new programmers that requires plenty of examples. More experienced programmers will find one or two examples are enough to master most of JavaFX, so a lot of web sites only put one or two examples up—enough for experienced programmers, but not nearly enough for newer programmers.
In this post, I present the classic temperature converter example modified to use JavaFX. This example uses basic MVC/MVP design. If you want to see this same JavaFX tutorial written in pure Java, look for my other tutorial on this site. It will be the one mentioning pure Java instead of FXML.
Sometimes it is easier to grasp the concepts of a language or library such as JavaFX by seeing it in action. I’ve put together a JavaFX image converter application. This JavaFX app allows you to drag GIF’s, JPEG’s, BMP’s, or PNG’s onto the ImageView and then convert them and save them quickly as any of the other formats mentioned above.
This JavaFX app is a double-clickable JAR file. That means that if you want to run it from the JAR file, just make sure you have Java installed and double-click the JavaFX JAR named image-converter.jar.