Skip to content

ThemeSwitcherController

Natalie L edited this page Dec 5, 2024 · 1 revision

The ThemeSwitcherController class is part of the controllers package (package org.example.globalgoodsindex.controllers). It is responsible for handling theme switching in the UI. The controller interacts with the ThemeManager to apply the selected theme and store the user's theme preferences. It provides a menu for selecting between different themes (light, dark, nord) using RadioMenuItems.

FXML

themeSwitcherController

Methods

initialize

Purpose:

Initializes the theme switcher by setting up the UI components, applying the saved theme, and handling user selection.

Description:


initializeToggleGroup

Purpose:

Sets the ToggleGroup for the theme menu items.

Description:

  • Associates each RadioMenuItem with the same ToggleGroup to ensure that only one option can be selected at a time.

selectMenuItemForTheme

Purpose:

Selects the appropriate menu item based on the saved theme.

Description:

  • Checks the saved theme and selects the corresponding RadioMenuItem (e.g., lightThemeMenuItem for " PrimerLight").

bindStrings

Purpose:

Binds the text property of the theme switcher menu to a language resource.

Description:

  • Uses L10N.createStringBinding() to bind the text of the theme switcher to a language string, enabling internationalization.

Clone this wiki locally