Creating the Project
NetBeans provides some out-of-the-box capabilities in terms of organizing your work. The Project is the top-level directory in which all operations take place. Sub-directories are established for Java Packages and Libraries. Output from various build operations (compilation, deployment, etc) are maintained in separate folders.
For the Date Difference Calculator I created a new Project as a JavaFX Application using the Project wizard in the NetBeans IDE. I created a simple package structure within the Project with the three packages I sketched out in the original design: User Interface (datecalculator package), Calculations (dcops package), and Data Store (dcstore package). You create a package from the File menu by selecting New File and choosing Java Package from the list of file types. The result is the structure shown in Figure 2. Note that the Project view lists the key Java libraries that a standard application requires (Java libraries are physically located in the directory/folder where you installed Java, for example, C:\Program Files\Java\jdk1.8.0_05\jre\lib)
Figure 2 – Initial Project and Package creation
At the risk of getting a little ahead of myself, here is a snapshot of the NetBeans File Panel, showing the breakdown of directories after I was done with a majority of the implementation (Figure 3). Note that the directories under the Project are created and managed by NetBeans; your work (the Java code) is maintained in the src folder, appropriately enough, and organized by package name. Figure 4 is a diagrammatic representation of the class interactions (quasi-functional flow diagram).
Figure 3 – File Organization
Figure 4 – Class Organization and Interaction
Let's take a look at some code behind the initial Project...