Class GUIComboBox<T>

Type Parameters:
T - the type of the entries of this list
All Implemented Interfaces:
GUIElement, ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
GUICharOptionsComboBox, GUIClassesComboBox, GUIRacesComboBox, GUIStartingMapsComboBox

public abstract class GUIComboBox<T> extends AbstractGUIElement
A GUIElement that displays a combo box.
See Also:
  • Constructor Details

    • GUIComboBox

      protected GUIComboBox(@NotNull @NotNull TooltipManager tooltipManager, @NotNull @NotNull GUIElementListener elementListener, @NotNull @NotNull String name, @Nullable @Nullable GUILabelLog label, @NotNull @NotNull GuiFactory guiFactory)
      Creates a new instance.
      Parameters:
      tooltipManager - the tooltip manager to update
      elementListener - the element listener to notify
      name - the name of this element
      label - the label to update or null
      guiFactory - the global GUI factory instance
  • Method Details

    • dispose

      public void dispose()
      Description copied from interface: GUIElement
      Releases all allocated resources.
      Specified by:
      dispose in interface GUIElement
      Overrides:
      dispose in class AbstractGUIElement
    • getPreferredSize

      public Dimension getPreferredSize()
      Overrides:
      getPreferredSize in class JComponent
    • getMinimumSize

      public Dimension getMinimumSize()
      Overrides:
      getMinimumSize in class JComponent
    • setBounds

      public void setBounds(int x, int y, int width, int height)
      Overrides:
      setBounds in class Component
    • updateModel

      protected void updateModel(@Nullable @Nullable List<T> elements)
      Updates entries shown in the combo box.
      Parameters:
      elements - the new entries to show
    • getListCellRendererComponent

      @NotNull protected abstract @NotNull Component getListCellRendererComponent(@NotNull @NotNull JList<? extends T> list, @Nullable T value, int index, boolean selected, boolean cellHasFocus)
      Returns a Component that displays the value.
      Parameters:
      list - the list that contains the value
      value - the value that is displayed or null
      index - the list index
      selected - whether the value is selected
      cellHasFocus - whether the value has the focus
      Returns:
      the component to render the value
    • updateSelectedItem

      protected void updateSelectedItem()
      Called whenever the selected item has changed.
    • updateSelectedItem

      protected abstract void updateSelectedItem(@Nullable T item)
      Will be called whenever the selected item has changed.
      Parameters:
      item - the selected item
    • setSelectedItem

      protected void setSelectedItem(@NotNull T item)
      Updates the selected item.
      Parameters:
      item - the new selected item
    • getDescription

      @NotNull protected abstract @NotNull String getDescription(@Nullable T item)
      Returns the description for an item.
      Parameters:
      item - the item
      Returns:
      the description
    • getTooltip

      @Nullable public @Nullable TooltipText getTooltip()
      Description copied from class: AbstractGUIElement
      Returns the current tooltip text.
      Specified by:
      getTooltip in class AbstractGUIElement
      Returns:
      the tooltip text or null to not show a tooltip