
Build a practical JavaFX application from the ground up, simulating a supermarket self-checkout with barcode scanner and coin machine, using MVC and object-oriented principles.
Discover how JavaFX UIs come from code or FXML, an XML-based language, and are edited with Scene Builder, including VBox and HBox layouts and an anchor pane.
Download and install the JavaFX Scene Builder, compare the standalone and IntelliJ versions, configure the destination folder, and open fxml files in Scene Builder from IntelliJ to streamline UI design.
Explore the hello application class in JavaFX, uncovering the stage, scene, and node structure, and explain how the start method, init, and main launch sequence initialize the UI.
Learn to switch between the welcome and scan items screens in JavaFX by handling action events and setting a new scene loaded from FXML.
Implement a navigator to manage stage and switch scenes, loading resources by path, with error handling and a single global instance via the self checkout application to enable centralized navigation.
Create reusable custom components by defining an article view as a self-contained VBox-based node, enabling instantiation, composition, and easy customization via constructors, padding, and color.
Style the JavaFX list view with css to toggle white and gray stripes for filled rows, keep empty cells white, and refine selected state using list cell selectors.
Create a money binding for payment due by subtracting paid from total, with dependencies on total and paid, then bind the label text to this binding.
Build and switch between payment options and payment info views in JavaFX using fxml, scene builder, and a VBox layout with computed sizing and styles.
Develop a greedy coin dispense algorithm that minimizes coins by using the largest denomination first and subtracting its value from the change, implemented with two loops.
Create the receipt screen with fxml and scene builder, using vbox and hbox layouts, labels and yes/no buttons, styled by receipt styles, and navigate from the payment screen to receipt.
Refactor the receipt generation by creating a generate receipt items method and a generate content HTML method to build an HTML table from receipt items and print the receipt.
The goal of this course is to help learners bridge the gap between basic programs and professional applications. This is achieved by building something found in the real world, a self-checkout machine, and by introducing more advanced concepts into the design. For example, real-world applications often use dependency injection (DI) for objects’ dependencies. We instead use a simpler method that achieves a similar purpose but also clarifies the usefulness of DI. We also dip our toes into component lifecycles and how subtle bugs can arise when components may be created and destroyed at any time. Therefore we crucially manage these lifecycles.
In part one of the course, we look at a basic JavaFX application and the fundamental tools at our disposal for building JavaFX UIs.
In part two, we dive into writing the self-checkout application, starting with an overview of the various classes and then building out the first two screens as well as creating a systematic way to navigate between them.
In part three, we create a virtual barcode scanner and hook it up to the main application using events. When a barcode is scanned, we look up the product and store this data in an appropriate place (the model). We make use of JavaFX properties, which are like supercharged variables. Properties enable us to bind the UI to the data so that the UI updates in real time. We also create custom UI components which are necessary to display scanned products to the customer in a clean and professional way.
In part four, we use CSS and stylesheets give the application a clean and consistent styling.
In part five, we move on to enabling payment. We create the payment screen along with the coin machine device. We calculate and display various figures such as the payment and the customer’s change using properties and bindings. We change the way money is represented to give us more control over its implementation. We introduce a lifecycle event to inform us of the destruction of our controllers to enable crucial clean-up. We create a mechanism for accepting or rejecting coins and giving the correct amount of change based on the coins available.
In part six, we create the receipt screen and receipt printer device. We pull the data from the model and format it into a suitable receipt and show it on the screen.