Welcome to the Jukebox JavaFX Tutorial

This documentation is designed for students who have a basic understanding of Java and want to learn JavaFX. We'll use the Jukebox project as a reference implementation to explain key JavaFX concepts through practical, hands-on examples.

What is the Jukebox Project?

The Jukebox is a music library management application that allows users to browse, play, and manage their music collection. It demonstrates a complete JavaFX application with multiple views, data persistence, and a clean MVC (Model-View-Controller) architecture.

What You'll Learn

This tutorial covers:

Prerequisites

  • Java Knowledge: You should understand basic Java concepts like classes, methods, variables, and loops.
  • Java 25+: The project uses Java 25 features and JavaFX 25. You need JDK 25 or later.
  • IDE: We recommend IntelliJ IDEA (Community Edition is free), but any Java IDE will work.
  • JavaFX SDK: You'll need the JavaFX SDK (version 25.0.4 is used in this project).
  • Cookbook Sections

    Browse our collection of how-to guides that walk you through specific JavaFX tasks using real code from the Jukebox project:

    Creating a Basic JavaFX Application

    Learn how to create your first JavaFX application by extending the Application class, setting up the primary stage, and launching your app.

    Jukebox.java module-info.java

    Read More

    Working with FXML Views

    Discover how to define your UI declaratively using FXML files and load them with FXMLLoader.

    application-window.fxml ApplicationWindowController.java

    Read More

    Creating Controllers

    Learn how controllers handle user interactions, receive FXML-injected elements, and manage view lifecycle with the initialize() method.

    All Controller classes

    Read More

    Navigation Between Views

    Understand the single-window architecture and how to switch between different views using a container-based approach.

    ApplicationWindowController.java Jukebox.java

    Read More

    Working with Data Models

    Create simple model classes to represent your application data, including enums and composition relationships.

    Album.java Song.java Genre.java

    Read More

    Working with Lists

    Master ListView configuration, ObservableList usage, selection handling, and working with collections.

    AdminPanelController.java

    Read More

    Adding Items to a List

    Implement add functionality for your ListView, including creating new objects, adding to collections, and auto-selecting new items.

    AdminPanelController.java

    Read More

    Removing Items from a List

    Learn how to safely remove items from ListView with confirmation dialogs, including proper cleanup of selection state.

    AdminPanelController.java

    Read More

    Editing Items in a List

    Implement two-way editing of list items using selection listeners, TextField listeners, and automatic ListView refresh.

    AdminPanelController.java

    Read More

    Using TableView

    Display tabular data with TableView, configure columns with cell value factories, and handle row selection.

    ChooseAlbumController.java choose-album-view.fxml

    Read More

    Saving and Loading with Gson

    Serialize and deserialize your application data to JSON files using the Gson library for easy persistence.

    Database.java module-info.java

    Read More

    Working with ComboBox

    Populate a ComboBox from enum values, set default selections, and respond to user selections with change listeners.

    AdminPanelController.java

    Read More

    Using SplitPane

    Create resizable, divider-based layouts with SplitPane to organize complex UIs into separate, adjustable sections.

    admin-panel-view.fxml

    Read More

    Working with Alerts and Dialogs

    Show confirmation dialogs and information alerts to users, and handle their responses in your application logic.

    AdminPanelController.java

    Read More

    Styling with CSS

    Apply CSS stylesheets to your JavaFX application to create a custom look and feel, just like styling web pages.

    application-window.fxml application-window.css

    Read More

    Controller Communication

    Understand how controllers can communicate with each other using static references and global state management.

    Jukebox.java

    Read More

    Auto-Save and Data Persistence

    Implement automatic saving of data when users navigate between views, preventing data loss from forgotten saves.

    ApplicationWindowController.java

    Read More

    How to Use This Documentation

  • Browse by Topic: Use the navigation bar at the top to jump directly to any section that interests you.
  • Follow Along: Each cookbook section references actual files in the Jukebox project. Open those files in your IDE and follow along with the explanations.
  • Try It Yourself: After reading each section, try modifying the code or creating your own similar implementation.
  • Experiment: Break things, fix them, and learn from your mistakes. That's the best way to learn!
  • Tip for Students: Start with the "Getting Started" section if you're new to JavaFX. Then work through the cookbook sections in order, as each builds on concepts from the previous ones.