Class GListCellRenderer<E>

Type Parameters:
E - the element-type this list models.
All Implemented Interfaces:
GComponent, FontChangeListener, ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible, ListCellRenderer<E>, SwingConstants
Direct Known Subclasses:
GComboBoxCellRenderer

public class GListCellRenderer<E> extends AbstractGCellRenderer implements ListCellRenderer<E>
Provides a common implementation of a list renderer, for use in both JList and JComboBox.

HTML rendering defaults to disabled. See GComponent.setHTMLRenderingEnabled(boolean).

See Also:
  • Constructor Details

    • GListCellRenderer

      public GListCellRenderer()
  • Method Details

    • createDefaultTextRenderer

      public static <E> GListCellRenderer<E> createDefaultTextRenderer(Function<E,String> cellToTextMappingFunction)
      Returns a new renderer that maps the list's data instance to a string used in the cell.

      Use this if you only need to provide a way to get the string value from the type being shown in the list.

      Parameters:
      cellToTextMappingFunction - a function that maps your custom type to a string value
      Returns:
      new GListCellRenderer instance
    • initBorders NEW

      protected void initBorders()
    • updateUI NEW

      public void updateUI()
      Overrides:
      updateUI in class AbstractHtmlLabel
    • getMaxBorderWidth NEW

      protected int getMaxBorderWidth()
      Gets the max border size for the default borders used by this renderer. If any subclass or client uses borders other than 'noFocusBorder' or 'focusBorder', then they will need to override this method if any of their borders have bigger insets than the default borders of this class.
      Returns:
      the largest known border width
    • getDefaultBackgroundColor

      protected Color getDefaultBackgroundColor()
      Overrides:
      getDefaultBackgroundColor in class AbstractGCellRenderer
    • getItemText

      protected String getItemText(E value)
      Return the cell renderer text
      Parameters:
      value - Cell object value
      Returns:
      A string interpretation of value; generated by calling value.toString()
    • getListCellRendererComponent

      public Component getListCellRendererComponent(JList<? extends E> list, E value, int index, boolean isSelected, boolean hasFocus)
      Specified by:
      getListCellRendererComponent in interface ListCellRenderer<E>
    • setForegroundColor

      protected void setForegroundColor(JList<? extends E> list, ListModel<? extends E> model, Object value)
    • configureFont

      protected void configureFont(JList<? extends E> list, ListModel<? extends E> model, int index)