# 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

- ## Field Summary

  ### Fields inherited from class Component

  `BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, CROSSHAIR_CURSOR, DEFAULT_CURSOR, DRAG_REGION_IMMEDIATELY_DRAG_X, DRAG_REGION_IMMEDIATELY_DRAG_XY, DRAG_REGION_IMMEDIATELY_DRAG_Y, DRAG_REGION_LIKELY_DRAG_X, DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y, DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X, DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, E_RESIZE_CURSOR, HAND_CURSOR, LEFT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NW_RESIZE_CURSOR, RIGHT, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, TOP, W_RESIZE_CURSOR, WAIT_CURSOR`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DefaultListCellRenderer()`
  Creates a new instance of DefaultCellRenderer
  `DefaultListCellRenderer(boolean showNumbers)`
  Creates a new instance of DefaultCellRenderer

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Component`
  `getCellRendererComponent(Component list, Object model, T value, int index, boolean isSelected)`
  Returns a component instance that is already set to render "value".
  `Component`
  `getFocusComponent(Component list)`
  Returns a component instance that is painted under the currently focused renderer and is animated to provide smooth scrolling.
  `Component`
  `getListCellRendererComponent(List list, T value, int index, boolean isSelected)`
  Returns a component instance that is already set to render "value".
  `Component`
  `getListFocusComponent(List list)`
  Returns a component instance that is painted under the currently focused renderer and is animated to provide smooth scrolling.
  `int`
  `getSelectionTransparency()`
  The background transparency factor to apply to the selection focus
  `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.
  `protected void`
  `initLaf(UIManager uim)`
  This method initializes the Component defaults constants
  `boolean`
  `isAlwaysRenderSelection()`
  Indicates that selection should always be rendered regardless of the status of the shouldRenderSelection flag
  `boolean`
  `isRightAlignNumbers()`

  ###### Returns

  `boolean`
  `isShowNumbers()`
  Indicate whether numbering should exist for the default cell renderer
  `static boolean`
  `isShowNumbersDefault()`
  Indicates whether the default list cell renderer will show numbers by default when constructed
  `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!
  `void`
  `repaint()`
  Overriden to do nothing and remove a performance issue where renderer changes perform needless repaint calls
  `void`
  `setAlwaysRenderSelection(boolean alwaysRenderSelection)`
  Indicates that selection should always be rendered regardless of the status of the shouldRenderSelection flag
  `void`
  `setRightAlignNumbers(boolean rightAlignNumbers)`

  ###### Parameters

  `void`
  `setSelectionTransparency(int selectionTransparency)`
  The background transparency factor to apply to the selection focus
  `void`
  `setShowNumbers(boolean showNumbers)`
  Indicate whether numbering should exist for the default cell renderer
  `static void`
  `setShowNumbersDefault(boolean def)`
  Indicates whether the default list cell renderer will show numbers by default when constructed

  ### Methods inherited from class Label

  `animate, bindProperty, calcPreferredSize, getAlignment, getBadgeStyleComponent, getBadgeText, getBaseline, getBaselineResizeBehavior, getBindablePropertyNames, getBindablePropertyTypes, getBoundPropertyValue, getDefaultGap, getFontIcon, getFontIconSize, getGap, getIcon, getIconFont, getIconStyleComponent, getIconUIID, getMask, getMaskedIcon, getMaskName, getMaterialIcon, getMaterialIconSize, getMaxAutoSize, getMinAutoSize, getPropertyNames, getPropertyTypeNames, getPropertyTypes, getPropertyValue, getShiftMillimeters, getShiftMillimetersF, getShiftText, getStringWidth, getText, getTextPosition, getTextSelectionSupport, getVerticalAlignment, initUnselectedStyle, isAutoSizeMode, isDefaultTickerEnabled, isEndsWith3Points, isLegacyRenderer, isShouldLocalize, isShowEvenIfBlank, isTextSelectionEnabled, isTickerEnabled, isTickerRunning, laidOut, paint, paramString, setAlignment, setAutoSizeMode, setBadgeText, setBadgeUIID, setBoundPropertyValue, setDefaultGap, setDefaultTickerEnabled, setEndsWith3Points, setFontIcon, setFontIcon, setFontIcon, setGap, setIcon, setIconUIID, setLegacyRenderer, setMask, setMaskName, setMaterialIcon, setMaterialIcon, setMaxAutoSize, setMinAutoSize, setPropertyValue, setShiftMillimeters, setShiftMillimeters, setShiftText, setShouldLocalize, setShowEvenIfBlank, setText, setTextPosition, setTextSelectionEnabled, setTickerEnabled, setUIID, setVerticalAlignment, shouldTickerStart, startTicker, startTicker, stopTicker, styleChanged, unbindProperty`

  ### Methods inherited from class Component

  `addDragFinishedListener, addDragOverListener, addDropListener, addFocusListener, addLongPressListener, addPointerDraggedListener, addPointerPressedListener, addPointerReleasedListener, addPullToRefresh, addScrollListener, addStateChangeListener, announceForAccessibility, blocksSideSwipe, calcScrollSize, cancelRepaints, clearClientProperties, contains, containsOrOwns, createStyleAnimation, deinitialize, deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver, dragInitiated, drawDraggedImage, drop, fireClicked, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getAccessibilityText, getAllStyles, getAnimationManager, getBorder, getBottomGap, getBounds, getBounds, getClientProperty, getCloudBoundProperty, getCloudDestinationProperty, getComponentForm, getComponentState, getCursor, getDefaultDragTransparency, getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed, getDragTransparency, getEditingDelegate, getGridPosX, getGridPosY, getHeight, getInlineAllStyles, getInlineDisabledStyles, getInlinePressedStyles, getInlineSelectedStyles, getInlineStylesTheme, getInlineUnselectedStyles, getInnerHeight, getInnerPreferredH, getInnerPreferredW, getInnerWidth, getInnerX, getInnerY, getLabelForComponent, getName, getNativeOverlay, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getOuterHeight, getOuterPreferredH, getOuterPreferredW, getOuterWidth, getOuterX, getOuterY, getOwner, getParent, getPreferredH, getPreferredSize, getPreferredSizeStr, getPreferredTabIndex, getPreferredW, getPressedStyle, getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getSideGap, getTabIndex, getTensileLength, getTooltip, getUIID, getUIManager, getUnselectedStyle, getVisibleBounds, getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFixedPreferredSize, hasFocus, hideNativeOverlay, initComponent, initCustomStyle, initDisabledStyle, initPressedStyle, initSelectedStyle, installDefaultPainter, isAlwaysTensile, isBlockLead, isCellRenderer, isChildOf, isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isEditable, isEditing, isEnabled, isFlatten, isFocusable, isGrabsPointerEvents, isHidden, isHidden, isHideInLandscape, isHideInPortrait, isIgnorePointerEvents, isInClippingRegion, isInitialized, isOpaque, isOwnedBy, isPinchBlocksDragAndDrop, isRippleEffect, isRTL, isScrollable, isScrollableX, isScrollableY, isScrollVisible, isSelectableInteraction, isSetCursorSupported, isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled, isTraversable, isVisible, keyPressed, keyReleased, keyRepeated, longKeyPress, longPointerPress, onScrollX, onScrollY, onSetFocusable, paintBackground, paintBackgrounds, paintBorder, paintBorderBackground, paintComponent, paintComponent, paintIntersectingComponentsAbove, paintLock, paintLockRelease, paintRippleOverlay, paintScrollbars, paintScrollbarX, paintScrollbarY, paintShadows, parsePreferredSize, pinch, pinch, pinchReleased, pointerDragged, pointerDragged, pointerHover, pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerPressed, pointerReleased, pointerReleased, putClientProperty, refreshTheme, refreshTheme, remove, removeDragFinishedListener, removeDragOverListener, removeDropListener, removeFocusListener, removeLongPressListener, removePointerDraggedListener, removePointerPressedListener, removePointerReleasedListener, removeScrollListener, removeStateChangeListener, repaint, requestFocus, resetFocusable, respondsToPointerEvents, scrollRectToVisible, scrollRectToVisible, setAccessibilityText, setAlwaysTensile, setBlockLead, setCellRenderer, setCloudBoundProperty, setCloudDestinationProperty, setComponentState, setCursor, setDefaultDragTransparency, setDirtyRegion, setDisabledStyle, setDraggable, setDragTransparency, setDropTarget, setEditingDelegate, setEnabled, setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden, setHidden, setHideInLandscape, setHideInPortrait, setIgnorePointerEvents, setInitialized, setInlineAllStyles, setInlineDisabledStyles, setInlinePressedStyles, setInlineSelectedStyles, setInlineStylesTheme, setInlineUnselectedStyles, setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setOpaque, setOwner, setPinchBlocksDragAndDrop, setPreferredH, setPreferredSize, setPreferredSizeStr, setPreferredTabIndex, setPreferredW, setPressedStyle, setRippleEffect, setRTL, setSameHeight, setSameSize, setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setShouldCalcPreferredSize, setSize, setSmoothScrolling, setSnapToGrid, setTabIndex, setTactileTouch, setTensileDragEnabled, setTensileLength, setTooltip, setTraversable, setUIID, setUIIDFinal, setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, shouldRenderComponentSelection, showNativeOverlay, startEditingAsync, stopEditing, stripMarginAndPadding, toImage, toString, updateNativeOverlay, visibleBoundsContains`

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## 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