public class DefaultListCellRenderer<T>

  1. Object
  2. Component
  3. Label
  4. DefaultListCellRenderer

ImplementsAnimation, CellRenderer<T>, Editable, IconHolder, ListCellRenderer<T>, StyleListener, TextHolder

Default implementation of the renderer based on a label see the ListCellRenderer for more information about the use and purpose of this class

Constructors

public DefaultListCellRenderer()Creates a new instance of DefaultCellRenderer
public DefaultListCellRenderer(boolean showNumbers)Creates a new instance of DefaultCellRenderer

Methods

public static boolean isShowNumbersDefault()Indicates whether the default list cell renderer will show numbers by default when constructed
public static void setShowNumbersDefault(boolean def)Indicates whether the default list cell renderer will show numbers by default when constructed
protected void initLaf(UIManager uim)This method initializes the Component defaults constants
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!
public Component getCellRendererComponent(Component list, Object model, T value, int index, boolean isSelected)Returns a component instance that is already set to render “value”.
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.
public Component getListCellRendererComponent(List list, T value, int index, boolean isSelected)Returns a component instance that is already set to render “value”.
public Component getListFocusComponent(List list)Returns a component instance that is painted under the currently focused renderer and is animated to provide smooth scrolling.
public void repaint()Overriden to do nothing and remove a performance issue where renderer changes perform needless repaint calls
public boolean isShowNumbers()Indicate whether numbering should exist for the default cell renderer
public void setShowNumbers(boolean showNumbers)Indicate whether numbering should exist for the default cell renderer
public int getSelectionTransparency()The background transparency factor to apply to the selection focus
public void setSelectionTransparency(int selectionTransparency)The background transparency factor to apply to the selection focus
public Component getFocusComponent(Component list)Returns a component instance that is painted under the currently focused renderer and is animated to provide smooth scrolling.
public boolean isRightAlignNumbers()
public void setRightAlignNumbers(boolean rightAlignNumbers)
public boolean isAlwaysRenderSelection()Indicates that selection should always be rendered regardless of the status of the shouldRenderSelection flag
public void setAlwaysRenderSelection(boolean alwaysRenderSelection)Indicates that selection should always be rendered regardless of the status of the shouldRenderSelection flag

Inherited fields

Inherited methods

From Component

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

Constructor details

DefaultListCellRenderer

public DefaultListCellRenderer()
Creates a new instance of DefaultCellRenderer

DefaultListCellRenderer

public DefaultListCellRenderer(boolean showNumbers)
Creates a new instance of DefaultCellRenderer

Parameters

showNumbers boolean
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 boolean
true to show numbers for all renderers created in the future

initLaf

protected void initLaf(UIManager uim)
This method initializes the Component defaults constants

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 boolean
indicates if the current styles should be merged with the new styles

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 Component
the list component
model Object
the model behind the render
value T
the value to render
index int
the index in the list
isSelected boolean
whether the entry is selected

Returns

a component to paint within the list

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

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 List
the list component
value T
the value to render
index int
the index in the list
isSelected boolean
whether the entry is selected

Returns

a component to paint within the list

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 List
the parent list

Returns

a component to use as focus

repaint

public void repaint()
Overriden to do nothing and remove a performance issue where renderer changes perform needless repaint calls

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 boolean
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 int
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 Component
the parent list

Returns

a component to use as focus

isRightAlignNumbers

public boolean isRightAlignNumbers()

Returns

the rightAlignNumbers

setRightAlignNumbers

public void setRightAlignNumbers(boolean rightAlignNumbers)

Parameters

rightAlignNumbers boolean
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 boolean
the alwaysRenderSelection to set