Class LocalizableJDialog

All Implemented Interfaces:
dev.javai18n.core.Localizable, ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants

public class LocalizableJDialog extends JDialog implements dev.javai18n.core.Localizable
A LocalizableJDialog class that supports localizing the title, font, name, accessible name, accessible description and icon images from an associated ResourceBundle.
See Also:
  • Field Details

    • DIALOG_PROPERTIES_KEY

      public static final String DIALOG_PROPERTIES_KEY
      The key value used to retrieve the Dialog's localizable properties.
      See Also:
  • Constructor Details

    • LocalizableJDialog

      protected LocalizableJDialog() throws HeadlessException
      Constructs an ownerless LocalizableJDialog with a title from the associated ResourceBundle.
      Throws:
      HeadlessException - if GraphicsEnvironment.isHeadless() returns true.
    • LocalizableJDialog

      protected LocalizableJDialog(Frame owner)
      Constructs a LocalizableJDialog with the specified owner Frame.
      Parameters:
      owner - The Frame from which the dialog is displayed.
    • LocalizableJDialog

      protected LocalizableJDialog(Dialog owner)
      Constructs a LocalizableJDialog with the specified owner Dialog.
      Parameters:
      owner - The Dialog from which the dialog is displayed.
    • LocalizableJDialog

      protected LocalizableJDialog(Window owner)
      Constructs a LocalizableJDialog with the specified owner Window.
      Parameters:
      owner - The Window from which the dialog is displayed.
  • Method Details

    • create

      public static LocalizableJDialog create()
      Creates and initializes a new ownerless LocalizableJDialog.
      Returns:
      A LocalizableJDialog with locale-sensitive attributes updated from an associated ResourceBundle.
    • create

      public static LocalizableJDialog create(Frame owner)
      Creates and initializes a new LocalizableJDialog with the specified owner Frame.
      Parameters:
      owner - The Frame from which the dialog is displayed.
      Returns:
      A LocalizableJDialog with locale-sensitive attributes updated from an associated ResourceBundle.
    • create

      public static LocalizableJDialog create(Dialog owner)
      Creates and initializes a new LocalizableJDialog with the specified owner Dialog.
      Parameters:
      owner - The Dialog from which the dialog is displayed.
      Returns:
      A LocalizableJDialog with locale-sensitive attributes updated from an associated ResourceBundle.
    • create

      public static LocalizableJDialog create(Window owner)
      Creates and initializes a new LocalizableJDialog with the specified owner Window.
      Parameters:
      owner - The Window from which the dialog is displayed.
      Returns:
      A LocalizableJDialog with locale-sensitive attributes updated from an associated ResourceBundle.
    • updateLocaleSpecificValues

      protected void updateLocaleSpecificValues()
      Updates locale-specific properties (title, font, name, accessible name, accessible description, and icon images) by reading a FramePropertyBundle from the resource bundle under the key "DialogProperties".

      Called by the create factory methods at construction time and by setBundleLocale(Locale) on each locale change. Subclasses may override this method to apply additional locale-specific values, and should call super.updateLocaleSpecificValues() first. A MissingResourceException (e.g. if the key is absent from the bundle) is logged at WARNING level and silently absorbed so that partial initialisation still succeeds.

    • getBundleLocale

      public Locale getBundleLocale()
      Get the Locale for ResourceBundles provided by this object.
      Specified by:
      getBundleLocale in interface dev.javai18n.core.Localizable
      Returns:
      The Locale for ResourceBundles provided by this object.
    • setBundleLocale

      public void setBundleLocale(Locale locale)
      Sets the bundle locale, fires a Localizable.LocaleEvent to all registered listeners, calls updateLocaleSpecificValues() to refresh this dialog's locale-specific properties, and calls Component.setLocale(Locale) to keep the AWT component locale in sync. Each registered Resourceful listener component also calls setLocale() on itself when it processes the event on the EDT.

      Always use setBundleLocale() to change the application locale. Calling Component.setLocale(Locale) directly updates the AWT rendering locale but does not reload bundle content or notify any listeners.

      Specified by:
      setBundleLocale in interface dev.javai18n.core.Localizable
      Parameters:
      locale - The new bundle locale.
    • getAvailableLocales

      public Locale[] getAvailableLocales()
      The available Locales for this object.
      Specified by:
      getAvailableLocales in interface dev.javai18n.core.Localizable
      Returns:
      An array of the available Locales for this object.
    • getResourceBundle

      public ResourceBundle getResourceBundle() throws dev.javai18n.core.NoCallbackRegisteredForModuleException
      Returns the ResourceBundle for the Locale that is currently set (by setBundleLocale) for this object.
      Specified by:
      getResourceBundle in interface dev.javai18n.core.Localizable
      Returns:
      The ResourceBundle for the Locale that is currently set (by setBundleLocale) for this object.
      Throws:
      dev.javai18n.core.NoCallbackRegisteredForModuleException - if a getBundle callback has not been registered for the module.
    • addLocaleEventListener

      public void addLocaleEventListener(dev.javai18n.core.Localizable.LocaleEventListener listener)
      Registers a listener to receive LocaleEvents when the Locale for ResourceBundles provided by this object is changed (via setBundleLocale).
      Specified by:
      addLocaleEventListener in interface dev.javai18n.core.Localizable
      Parameters:
      listener - The listener that will receive LocaleEvents.
    • removeLocaleEventListener

      public void removeLocaleEventListener(dev.javai18n.core.Localizable.LocaleEventListener listener)
      Unregisters a listener that is receiving LocaleEvents when the Locale for ResourceBundles provided by this object is changed (via setBundleLocale).
      Specified by:
      removeLocaleEventListener in interface dev.javai18n.core.Localizable
      Parameters:
      listener - The listener that will be unregistered from receiving LocaleEvents.