Inventory Manager

Updated on November 9th, 2021 at 1:09 am

What is it?

This was a course project that I completed for my first Java Class at my undergraduate university. The class was labeled Basic Java Concepts and covered all of the major foundations that make up the Java language. Classes with abstraction, interfaces, constructors, inheritance, etc. are some of the many topics discussed in that course. The JavaFX framework was also briefly taught and was used to build the final project.

The project was focused specifically on the software development phase of the SDLC (Software Development Life Cycle) so a project information document, a UML class diagram, and a GUI mockup document were all provided to complete the project. The screens that make up the application were directly modeled after the GUI mockup document. They are not of my own design.

screenshot of the inventory management app
A screenshot of the Inventory Management app

What does it do?

The Inventory Manager does just as it sounds. It manages inventory. The items are split between two types: Products and Parts. Both have information regarding the items including their name, their supply in your inventory, their price, and the minimum/maximum amount of those items that can fit in your inventory. Products are unique in that they can have associated parts. The idea is that every product can have one or many parts. Parts are unique in that they have two sub-types labeled “In House” and “Outsourced” which indicated whether the part was made by your company or if it was imported. Parts also have an additional field of data. They can have a Machine ID if they are an In-House part or a Company Name if they are an Outsourced part.

screenshot of the manage product screen
Modify Product Screen

Basically, the Inventory Manager is used to keep track of parts and products in an inventory. Add a part, modify a part, add a product, associate a part to it, and repeat. There are also search engines on the main screen and product screens to search for parts/products in your inventory.

How does it work?

The Inventory Manager was made completely with Java and JavaFX. The application consists of 5 screens, which means there are 5 JavaFX views and 5 controllers that manage the interface. Collectively there are 11 class files with one of them being the initializer and main method for the application. The Main.java file sets global variables and data sets that will be accessed by other classes across the application. It also includes the handleSceneChange method that will be called each time a new view needs to display.

Main.java handleSceneChange()

The method works by setting a Parent viewFile to a JavaFX FXML file which contains specialized XML tags exclusive to JavaFX. It will then create a new scene from the viewFile, create a new stage off of the Main files getter, and then set some attributes to that stage. The show() method will handle the display of the new scene. the stage.setOnCloseRequest method is used to show a confirmation alert when the user tries to exit the screen without saving.

Inventory.java

The Inventory.java file is the main class file that manages the creation, manipulation, and removal of Parts and Products in the application. The Parts and Products are represented as objects in the allParts and allProducts lists. In JavaFX, each list needs to be of the ObservableList type in order to exist in a visual table. lookupPart and lookupProduct are used in the search engines for some of the views. The other class files (Part.java, Product.java, Outsourced.java, and InHouse.java) have constructors to create those types of objects. They also contain internal getter/setter methods to obtain and update the properties of their associated objects. Part.java is shown below with its internal methods.

Object Class Files vs. Controller Class Files

The files Inventory.java, Part.java, Product.java, Outsourced.java, and InHouse.java are all Object Class files meaning that they represent instances of data within the application. In the Model View Controller (MVC) architecture, these represent the Models that control the data of the application.

The files InventoryController, AddPartController, AddProductController, ModifyPartController, and ModifyProductController are Controller Class files, meaning that they control the interaction of data within the application. In the MVC architecture, the controllers manage interactions of data between the Models and the Views. If a user types data into a field in a view, the controller is responsible for using the methods from the Models to create data from that field input. An example of this is the AddPartController where an object is created from clicking the save button in a form, after all of the fields are populated of course.

Views

JavaFX utilizes the Model View Controller (MVC) architecture to create applications. The Views are written in a modified version of the Extended Markup Language (XML) called FXML. The scripts are a lot like XML, but contain specific tags relating to the layouts and input controls provided by JavaFX. As an example, here is part of the AddPart.fxml file below. It creates the labels and text fields that make up most of the screen.

Links