Class BasicSettingsWindow

java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
com.everdro1d.libs.swing.windows.settings.BasicSettingsWindow
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants

public abstract class BasicSettingsWindow extends JFrame
A basic settings window that can be used to create a settings window for any application.

This class is abstract and must be extended to implement:

If a LocaleManager is passed, a locale switch will be shown automatically. For other settings you will need to create a JPanel and customize the above methods to use them.

See Also:
  • Constructor Details

    • BasicSettingsWindow

      public BasicSettingsWindow(JFrame parent, String fontName, int fontSize, Preferences prefs, boolean debug, LocaleManager localeManager, JPanel settingsPanel, String localeRepositoryURL, String helpWebsiteURL)
      Constructor for the BasicSettingsWindow.
      Parameters:
      parent - Parent frame to center the settings window on.
      fontName - Font name to use for the settings window.
      fontSize - Font size to use for the settings window.
      prefs - Preferences object to store settings.
      debug - Debug mode flag.
      localeManager - LocaleManager object for localization.
      settingsPanel - JPanel containing the settings components.
      localeRepositoryURL - URL for the locale repository.
      helpWebsiteURL - URL for the help website.
  • Method Details

    • applySettings

      public abstract void applySettings()
      Implement your actual save mechanism here.
    • setOriginalSettingsMap

      public abstract Map<String,String> setOriginalSettingsMap()
      Add current settings for GeneralSettingsPanel here ex:

      NOTE! Name these keys the same as your prefs keys!

           Map<String,String> originalSettings = new HashMap<>();
               originalSettings.put("currentLocale",
                   localeManager.getCurrentLocale())
               );
           return originalSettings;
       
      Returns:
      map that saves the original settings to reset any changes
    • setRestartRequiredSettingsMap

      public abstract Map<String,Boolean> setRestartRequiredSettingsMap()
      Add current settings for GeneralSettingsPanel here ex:

      NOTE! Name these keys the same as your prefs keys!

           Map<String,String> restartRequiredSettings = new HashMap<>();
               restartRequiredSettings.put("currentLocale", true));
           return restartRequiredSettings;
       
      Returns:
      map of settings that require a restart
    • getOriginalSettingsMap

      public Map<String,String> getOriginalSettingsMap()
      Retrieves the map of original settings.
      Returns:
      original settings map
    • getRestartRequiredSettingsMap

      public Map<String,Boolean> getRestartRequiredSettingsMap()
      Retrieves the map of settings that require a restart.
      Returns:
      restart required settings map