Package com.formdev.flatlaf.ui
Class FlatListUI
java.lang.Object
javax.swing.plaf.ComponentUI
javax.swing.plaf.ListUI
javax.swing.plaf.basic.BasicListUI
com.formdev.flatlaf.ui.FlatListUI
- All Implemented Interfaces:
FlatStylingSupport.StyleableUI
Provides the Flat LaF UI delegate for
JList
.
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.plaf.basic.BasicListUI
BasicListUI.FocusHandler, BasicListUI.ListDataHandler, BasicListUI.ListSelectionHandler, BasicListUI.MouseInputHandler, BasicListUI.PropertyChangeHandler
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Color
protected Insets
protected int
protected Color
protected Color
protected Color
protected Color
protected Insets
protected Boolean
Fields inherited from class javax.swing.plaf.basic.BasicListUI
cellHeight, cellHeights, cellRendererChanged, cellWidth, fixedCellHeightChanged, fixedCellWidthChanged, focusListener, fontChanged, list, listDataListener, listSelectionListener, modelChanged, mouseInputListener, propertyChangeListener, prototypeCellValueChanged, rendererPane, selectionModelChanged, updateLayoutStateNeeded
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
applyStyle
(Object style) protected Object
applyStyleProperty
(String key, Object value) protected FocusListener
protected ListSelectionListener
protected PropertyChangeListener
static ComponentUI
getStyleableValue
(JComponent c, String key) protected void
protected void
void
private void
protected void
paintCell
(Graphics g, int row, Rectangle rowBounds, ListCellRenderer cellRenderer, ListModel dataModel, ListSelectionModel selModel, int leadIndex) protected void
paintCellSelection
(Graphics g, int row, int x, int y, int width, int height) Paints (rounded) cell selection.static void
paintCellSelection
(JList<?> list, Graphics g, int row, int x, int y, int width, int height) Paints a cell selection at the given coordinates.private void
Toggle selection colors from focused to inactive and vice versa.protected void
private boolean
useUnitedRoundedSelection
(boolean vertical, boolean horizontal) Methods inherited from class javax.swing.plaf.basic.BasicListUI
convertRowToY, convertYToRow, createListDataListener, createMouseInputListener, getBaseline, getBaselineResizeBehavior, getCellBounds, getPreferredSize, getRowHeight, indexToLocation, installKeyboardActions, installListeners, locationToIndex, maybeUpdateLayoutState, paint, selectNextIndex, selectPreviousIndex, uninstallKeyboardActions, uninstallListeners, uninstallUI, updateLayoutState
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, getMaximumSize, getMinimumSize, update
-
Field Details
-
selectionBackground
-
selectionForeground
-
selectionInactiveBackground
-
selectionInactiveForeground
-
selectionInsets
- Since:
- 3
-
selectionArc
protected int selectionArc- Since:
- 3
-
cellMargins
- Since:
- 2
-
cellFocusColor
- Since:
- 2
-
showCellFocusIndicator
- Since:
- 2
-
oldStyleValues
-
-
Constructor Details
-
FlatListUI
public FlatListUI()
-
-
Method Details
-
createUI
-
installUI
- Overrides:
installUI
in classBasicListUI
-
installUIImpl
-
installDefaults
protected void installDefaults()- Overrides:
installDefaults
in classBasicListUI
-
uninstallDefaults
protected void uninstallDefaults()- Overrides:
uninstallDefaults
in classBasicListUI
-
createFocusListener
- Overrides:
createFocusListener
in classBasicListUI
-
createPropertyChangeListener
- Overrides:
createPropertyChangeListener
in classBasicListUI
-
createListSelectionListener
- Overrides:
createListSelectionListener
in classBasicListUI
-
installStyle
protected void installStyle()- Since:
- 2
-
applyStyle
- Since:
- 2
-
applyStyleProperty
- Since:
- 2
-
getStyleableInfos
- Specified by:
getStyleableInfos
in interfaceFlatStylingSupport.StyleableUI
- Since:
- 2
-
getStyleableValue
- Specified by:
getStyleableValue
in interfaceFlatStylingSupport.StyleableUI
- Since:
- 2.5
-
toggleSelectionColors
private void toggleSelectionColors()Toggle selection colors from focused to inactive and vice versa. This is not an optimal solution but much easier than rewriting the whole paint methods. Using a LaF specific renderer was avoided because often a custom renderer is already used in applications. Then either the inactive colors are not used, or the application has to be changed to extend a FlatLaf renderer. -
paintCell
protected void paintCell(Graphics g, int row, Rectangle rowBounds, ListCellRenderer cellRenderer, ListModel dataModel, ListSelectionModel selModel, int leadIndex) - Overrides:
paintCell
in classBasicListUI
-
paintCellSelection
Paints (rounded) cell selection. SupportsselectionArc
andselectionInsets
.Note: This method is only invoked if either selection arc is greater than zero or if selection insets are not empty.
- Since:
- 3
-
useUnitedRoundedSelection
private boolean useUnitedRoundedSelection(boolean vertical, boolean horizontal) -
paintCellSelection
public static void paintCellSelection(JList<?> list, Graphics g, int row, int x, int y, int width, int height) Paints a cell selection at the given coordinates. The selection color must be set on the graphics context.This method is intended for use in custom cell renderers to support
selectionArc
andselectionInsets
.- Since:
- 3
-