Class ResourcefulJTable

All Implemented Interfaces:
dev.javai18n.core.Localizable.LocaleEventListener, dev.javai18n.core.Resourceful, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, CellEditorListener, ListSelectionListener, RowSorterListener, TableColumnModelListener, TableModelListener, Scrollable

public class ResourcefulJTable extends JTable implements dev.javai18n.core.Resourceful, dev.javai18n.core.Localizable.LocaleEventListener
A JTable that participates in locale change events, allowing it to refresh column headers and cell renderers when the application locale changes.

Column header names are typically provided by the TableModel (via TableModel.getColumnName()), not by the property bundle. When the locale changes, ResourcefulJTable calls createDefaultColumnsFromModel() to force the table to re-read column names from the model and then calls repaint() so that locale-sensitive cell renderers (e.g. date formatters, number formatters) also redraw with the new locale. This means that any TableModel.getColumnName() implementation that reads from the current application locale will automatically produce correct column headers after a locale switch.

See Also:
  • Constructor Details

    • ResourcefulJTable

      protected ResourcefulJTable(dev.javai18n.core.Resource resource)
      Constructs a JTable bound to the given resource with no table model.
      Parameters:
      resource - The resource identifying the locale source and bundle key.
    • ResourcefulJTable

      protected ResourcefulJTable(dev.javai18n.core.Resource resource, TableModel model)
      Constructs a JTable bound to the given resource and table model.
      Parameters:
      resource - The resource identifying the locale source and bundle key.
      model - The TableModel to display.
  • Method Details

    • create

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

      public static ResourcefulJTable create(dev.javai18n.core.Resource resource, TableModel model)
      Create a ResourcefulJTable with the specified Resource and TableModel.
      Parameters:
      resource - A Resource containing a JComponentPropertyBundle.
      model - The TableModel to display.
      Returns:
      A ResourcefulJTable 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.