Class Main

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants

public class Main extends JFrame
Main application window for the 3D Print Job Tracker GUI.

This JFrame implementation is responsible for application startup tasks such as database initialization, integrity checks, scheduling backups and composing the primary UI (menu, main panel). The class is implemented as a singleton and is safe to obtain from other UI components via getInstance().

Since:
1.0.0
See Also:
  • Field Details

    • INTELLIJ_THEMES

      private static final Map<String, Class<? extends LookAndFeel>> INTELLIJ_THEMES
      Map of available IntelliJ themes for FlatLaf look and feel. Used to populate the Theme menu and apply selected theme.
    • projectForm

      private ProjectFormPanel projectForm
      Main project form panel displayed in the center of the window.
    • instance

      private static Main instance
      Singleton instance of the main application window.
  • Constructor Details

    • Main

      public Main()
      Constructs the main application window, initializes database, menu bar, and content. Sets the window to maximized and visible.
  • Method Details

    • getInstance

      public static Main getInstance()
      Return the singleton `Main` instance, creating it if necessary.
      Returns:
      the singleton `Main` instance
    • initializeDatabase

      private void initializeDatabase()
      Initializes the database tables if they do not exist. Shows an error dialog if initialization fails. This method creates the minimal schema used by the application. It is safe to call multiple times as the DDL uses "IF NOT EXISTS" checks.
    • verifyDatabaseAndScheduleBackups

      private void verifyDatabaseAndScheduleBackups()
      Verifies the integrity of the database and schedules automatic backups. If verification fails the application will exit with an error dialog.
    • createMenuBar

      private void createMenuBar()
      Creates the menu bar with File, Project, and Theme menus. Theme menu allows user to select color scheme. Each menu item is wired to an action method defined on this class.
    • showShortcutsDialog

      private void showShortcutsDialog(ActionEvent e)
      Shows a brief list of keyboard shortcuts in an information dialog.
      Parameters:
      e - the ActionEvent that triggered displaying shortcuts
    • createMainContent

      private void createMainContent()
      Sets up the main content area, including welcome label and project form panel.
    • openSearchDialog

      private void openSearchDialog(ActionEvent e)
      Opens the SearchDialog for searching projects.
      Parameters:
      e - the ActionEvent that triggered opening the dialog
    • scheduleDailyBackups

      private void scheduleDailyBackups()
      Schedules automatic daily database backups.
    • main

      public static void main(String[] args)
      Main entry point. Sets system look and feel and launches the application. Ensures GUI is created on the Event Dispatch Thread. Supported command-line behavior: the application attempts to load a saved theme from `app_settings.properties` and falls back to a light theme.
      Parameters:
      args - command-line arguments (ignored by the GUI)
    • performBackup

      private void performBackup(ActionEvent e)
      Create a backup of the H2 database file.
      Parameters:
      e - the ActionEvent that triggered the backup
    • performScheduledBackup

      private void performScheduledBackup()
      Perform a scheduled backup of the H2 database file. This is intended to be invoked by a timer task.
    • performRestore

      private void performRestore(ActionEvent e)
      Restore the database from a backup. Implementation may show a file chooser and perform the restore operation.
      Parameters:
      e - the ActionEvent that triggered the restore
    • exitApplication

      private void exitApplication(ActionEvent e)
      Exit the application immediately.
      Parameters:
      e - the ActionEvent that triggered exiting the application
    • toggleTheme

      private void toggleTheme(ActionEvent e)
      Apply the selected theme and persist the choice to settings.
      Parameters:
      e - the ActionEvent from the theme menu selection
    • showUserGuide

      private void showUserGuide(ActionEvent e)
      Display a brief user guide in a dialog.
      Parameters:
      e - the ActionEvent that triggered showing the user guide
    • showAboutDialog

      private void showAboutDialog(ActionEvent e)
      Show the About dialog containing version and author information.
      Parameters:
      e - the ActionEvent that triggered showing the About dialog
    • ensureConsistentFontSize

      private void ensureConsistentFontSize()
      Ensure a consistent large font is applied across common UI components. This is invoked on startup to improve readability on high-DPI displays.
    • loadProjectDetails

      public void loadProjectDetails(String name, String type, String description, String filePath)
      Loads the selected project details into the main form.
      Parameters:
      name - Project name
      type - Project type
      description - Project description
      filePath - File path of the project