Class DefaultListCellRenderer<T>

java.lang.Object
com.codename1.ui.Component
com.codename1.ui.Label
com.codename1.ui.list.DefaultListCellRenderer<T>
All Implemented Interfaces:
Animation, Editable, StyleListener, IconHolder, CellRenderer<T>, ListCellRenderer<T>, TextHolder

public class DefaultListCellRenderer<T> extends Label implements ListCellRenderer<T>, CellRenderer<T>
Default implementation of the renderer based on a label see the ListCellRenderer for more information about the use and purpose of this class
  • Constructor Details

    • DefaultListCellRenderer

      public DefaultListCellRenderer()
      Creates a new instance of DefaultCellRenderer
    • DefaultListCellRenderer

      public DefaultListCellRenderer(boolean showNumbers)

      Creates a new instance of DefaultCellRenderer

      Parameters
      • showNumbers: indicates numbers should be shown
  • Method Details

    • isShowNumbersDefault

      public static boolean isShowNumbersDefault()

      Indicates whether the default list cell renderer will show numbers by default when constructed

      Returns

      true when showing numbers, false otherwise

    • setShowNumbersDefault

      public static void setShowNumbersDefault(boolean def)

      Indicates whether the default list cell renderer will show numbers by default when constructed

      Parameters
      • def: true to show numbers for all renderers created in the future
    • initLaf

      protected void initLaf(UIManager uim)
      This method initializes the Component defaults constants
      Overrides:
      initLaf in class Label
    • refreshTheme

      public void refreshTheme(boolean merge)

      Makes sure the component is up to date with the current theme, ONLY INVOKE THIS METHOD IF YOU CHANGED THE THEME!

      Parameters
      • merge: indicates if the current styles should be merged with the new styles
      Overrides:
      refreshTheme in class Label
    • getCellRendererComponent

      public Component getCellRendererComponent(Component list, Object model, T value, int index, boolean isSelected)

      Returns a component instance that is already set to render "value". While it is not a requirement many renderes often derive from a component (such as a label) and return "this". Notice that a null value for the value argument might be sent when refreshing the theme of the list.

      Parameters
      • list: the list component

      • model: the model behind the render

      • value: the value to render

      • index: the index in the list

      • isSelected: whether the entry is selected

      Returns

      a component to paint within the list

      Specified by:
      getCellRendererComponent in interface CellRenderer<T>
    • getStyle

      public Style getStyle()

      Returns the current Component Style allowing code to draw the current component, you should normally use getUnselected/Pressed/DisabledStyle() and not this method since it will return different values based on component state.

      Returns

      the component Style object

      Overrides:
      getStyle in class Component
    • getListCellRendererComponent

      public Component getListCellRendererComponent(List list, T value, int index, boolean isSelected)

      Returns a component instance that is already set to render "value". While it is not a requirement many renderes often derive from a component (such as a label) and return "this". Notice that a null value for the value argument might be sent when refreshing the theme of the list.

      Parameters
      • list: the list component

      • value: the value to render

      • index: the index in the list

      • isSelected: whether the entry is selected

      Returns

      a component to paint within the list

      Specified by:
      getListCellRendererComponent in interface ListCellRenderer<T>
    • getListFocusComponent

      public Component getListFocusComponent(List list)

      Returns a component instance that is painted under the currently focused renderer and is animated to provide smooth scrolling. When the selection moves, this component is drawn above/below the list items - it is recommended to give this component some level of transparency (see above code example). This method is optional, an implementation can choose to return null.

      Parameters
      • list: the parent list
      Returns

      a component to use as focus

      See also
      • List#setSmoothScrolling
      Specified by:
      getListFocusComponent in interface ListCellRenderer<T>
    • repaint

      public void repaint()
      Overriden to do nothing and remove a performance issue where renderer changes perform needless repaint calls
      Overrides:
      repaint in class Component
    • isShowNumbers

      public boolean isShowNumbers()

      Indicate whether numbering should exist for the default cell renderer

      Returns

      true if numers are shown by the numbers

    • setShowNumbers

      public void setShowNumbers(boolean showNumbers)

      Indicate whether numbering should exist for the default cell renderer

      Parameters
      • showNumbers: indicate whether numbering should exist for the default cell renderer
    • getSelectionTransparency

      public int getSelectionTransparency()

      The background transparency factor to apply to the selection focus

      Returns

      selection transperancy value

    • setSelectionTransparency

      public void setSelectionTransparency(int selectionTransparency)

      The background transparency factor to apply to the selection focus

      Parameters
      • selectionTransparency: the selection transperancy value
    • getFocusComponent

      public Component getFocusComponent(Component list)

      Returns a component instance that is painted under the currently focused renderer and is animated to provide smooth scrolling. When the selection moves, this component is drawn above/below the list items - it is recommended to give this component some level of transparency (see above code example). This method is optional an implementation can choose to return null.

      Parameters
      • list: the parent list
      Returns

      a component to use as focus

      See also
      • List#setSmoothScrolling
      Specified by:
      getFocusComponent in interface CellRenderer<T>
    • isRightAlignNumbers

      public boolean isRightAlignNumbers()
      Returns

      the rightAlignNumbers

    • setRightAlignNumbers

      public void setRightAlignNumbers(boolean rightAlignNumbers)
      Parameters
      • rightAlignNumbers: the rightAlignNumbers to set
    • isAlwaysRenderSelection

      public boolean isAlwaysRenderSelection()

      Indicates that selection should always be rendered regardless of the status of the shouldRenderSelection flag

      Returns

      the alwaysRenderSelection

    • setAlwaysRenderSelection

      public void setAlwaysRenderSelection(boolean alwaysRenderSelection)

      Indicates that selection should always be rendered regardless of the status of the shouldRenderSelection flag

      Parameters
      • alwaysRenderSelection: the alwaysRenderSelection to set