Building the graphical user interface
For our GUI, we'd like to expose the same type of functionality as the command line, but, obviously, with a nice graphical interface. For this, we'll again reach for JavaFX. We'll give the user a means to select, using a chooser dialog, the directories to be searched, and a field by which to add the search patterns. Once the duplicates have been identified, we will display them in a list for the user to peruse. All of the duplicate groups will be listed and, when clicked, the files in that group will be displayed in another list. The user can right-click on the list and choose to either view the file (or files) or delete it (or them). When we are finished, the application will look like this:
Let's start by creating our project. In NetBeans, go to File
| New Project
and select Maven
| JavaFX Application
. You can name it whatever you'd like, but we've used the name Duplicate Finder - GUI
, groupId
as com.steeplesoft.dupefind
, and artifactId
as gui
.
Once...