-
Notifications
You must be signed in to change notification settings - Fork 1
MenuBarController Class
Natalie L edited this page Dec 5, 2024
·
1 revision
The MenuBarController class is part of the controllers package
(package org.example.globalgoodsindex.controllers) .
It manages the menus in the application’s menu bar, handling user interactions with the settings, view, and help menus. It opens a new window for the "About" section and opens the project's GitHub repository in the default browser.
Initializes the menu items and sets up their actions.
- Binds the menu and menu item text properties to localized strings.
- Sets action handlers for the GitHub menu item and the About menu item.
Binds the menu and menu item text to localized values.
- Binds the text of the menu items (settings, view, help, about, and GitHub) to their respective localized strings using
L10N.createStringBinding.
Opens a website URL in the default browser.
- Creates a new Task to open a URL in the
default system browser using
Desktop.browse(). - Runs the task in a new thread to avoid blocking the UI.
MenuBarController.openWebsite("https://github.com/bruch-alex/Global-Goods-Index");- Catches exceptions like invalid URLs and prints stack traces.
Opens the "About" window if it's not already open.
- Loads the
about.fxmlfile and displays it in a new stage if not already showing. - Sets the title and scene of the window and binds the title to a localized string.
- Ensures that only one instance of the "About" window can be shown at a time.
- Catches IOException for loading issues with a
bout.fxmland logs the error. - Catches general exceptions for unexpected errors.