Class ResourcefulJSpinner

All Implemented Interfaces:
dev.javai18n.core.Localizable.LocaleEventListener, dev.javai18n.core.Resourceful, ImageObserver, MenuContainer, Serializable, EventListener, Accessible

public class ResourcefulJSpinner extends JSpinner implements dev.javai18n.core.Resourceful, dev.javai18n.core.Localizable.LocaleEventListener
A JSpinner that participates in locale change events.

On locale change, this component updates its locale, accessible name, accessible description, tooltip, font, and component name from the resource bundle, then calls revalidate() and repaint() to trigger re-rendering of the embedded editor field. Because JSpinner.DateEditor and JSpinner.NumberEditor carry locale-specific format patterns baked into their formatters at construction time, callers that need the spinner's display format to switch locale should install a new editor in their own Localizable.LocaleEventListener registered on the same source.

See Also:
  • Constructor Details

    • ResourcefulJSpinner

      protected ResourcefulJSpinner(dev.javai18n.core.Resource resource)
      Constructs a JSpinner bound to the given resource with a default spinner model.
      Parameters:
      resource - The resource identifying the locale source and bundle key.
    • ResourcefulJSpinner

      protected ResourcefulJSpinner(dev.javai18n.core.Resource resource, SpinnerModel model)
      Constructs a JSpinner bound to the given resource and spinner model.
      Parameters:
      resource - The resource identifying the locale source and bundle key.
      model - The SpinnerModel to use.
  • Method Details

    • create

      public static ResourcefulJSpinner create(dev.javai18n.core.Resource resource)
      Create a ResourcefulJSpinner with the specified Resource and default spinner model.
      Parameters:
      resource - A Resource containing a JComponentPropertyBundle.
      Returns:
      A ResourcefulJSpinner registered to listen to LocaleEvents from the resource's source.
    • create

      public static ResourcefulJSpinner create(dev.javai18n.core.Resource resource, SpinnerModel model)
      Create a ResourcefulJSpinner with the specified Resource and SpinnerModel.
      Parameters:
      resource - A Resource containing a JComponentPropertyBundle.
      model - The SpinnerModel to use.
      Returns:
      A ResourcefulJSpinner registered to listen to LocaleEvents from the resource's source.
    • initialize

      protected final void initialize()
      Registers this component as a locale-event listener on its resource source and applies the initial locale-specific values from the resource bundle.
    • updateLocaleSpecificValues

      protected void updateLocaleSpecificValues()
      Applies locale-specific values from the associated resource bundle to this component.
    • processLocaleEvent

      public void processLocaleEvent(dev.javai18n.core.Localizable.LocaleEvent event)
      Specified by:
      processLocaleEvent in interface dev.javai18n.core.Localizable.LocaleEventListener
    • getResource

      public dev.javai18n.core.Resource getResource()
      Specified by:
      getResource in interface dev.javai18n.core.Resourceful
    • setResource

      public void setResource(dev.javai18n.core.Resource resource)
      Specified by:
      setResource in interface dev.javai18n.core.Resourceful
    • dispose

      public void dispose()
      Unregister this component as a locale-event listener on its resource's source. Call this when the component is being permanently discarded so that it does not accumulate in the source's listener list.