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
public class FlatListUI extends javax.swing.plaf.basic.BasicListUI implements FlatStylingSupport.StyleableUI
Provides the Flat LaF UI delegate forJList
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.plaf.basic.BasicListUI
javax.swing.plaf.basic.BasicListUI.FocusHandler, javax.swing.plaf.basic.BasicListUI.ListDataHandler, javax.swing.plaf.basic.BasicListUI.ListSelectionHandler, javax.swing.plaf.basic.BasicListUI.MouseInputHandler, javax.swing.plaf.basic.BasicListUI.PropertyChangeHandler
-
-
Field Summary
Fields Modifier and Type Field Description protected java.awt.Color
cellFocusColor
protected java.awt.Insets
cellMargins
private java.util.Map<java.lang.String,java.lang.Object>
oldStyleValues
protected int
selectionArc
protected java.awt.Color
selectionBackground
protected java.awt.Color
selectionForeground
protected java.awt.Color
selectionInactiveBackground
protected java.awt.Color
selectionInactiveForeground
protected java.awt.Insets
selectionInsets
protected java.lang.Boolean
showCellFocusIndicator
-
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 Constructor Description FlatListUI()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
applyStyle(java.lang.Object style)
protected java.lang.Object
applyStyleProperty(java.lang.String key, java.lang.Object value)
protected java.awt.event.FocusListener
createFocusListener()
protected javax.swing.event.ListSelectionListener
createListSelectionListener()
protected java.beans.PropertyChangeListener
createPropertyChangeListener()
static javax.swing.plaf.ComponentUI
createUI(javax.swing.JComponent c)
java.util.Map<java.lang.String,java.lang.Class<?>>
getStyleableInfos(javax.swing.JComponent c)
java.lang.Object
getStyleableValue(javax.swing.JComponent c, java.lang.String key)
protected void
installDefaults()
protected void
installStyle()
void
installUI(javax.swing.JComponent c)
private void
installUIImpl(javax.swing.JComponent c)
protected void
paintCell(java.awt.Graphics g, int row, java.awt.Rectangle rowBounds, javax.swing.ListCellRenderer cellRenderer, javax.swing.ListModel dataModel, javax.swing.ListSelectionModel selModel, int leadIndex)
protected void
paintCellSelection(java.awt.Graphics g, int row, int x, int y, int width, int height)
Paints (rounded) cell selection.static void
paintCellSelection(javax.swing.JList<?> list, java.awt.Graphics g, int row, int x, int y, int width, int height)
Paints a cell selection at the given coordinates.private void
toggleSelectionColors()
Toggle selection colors from focused to inactive and vice versa.protected void
uninstallDefaults()
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
-
-
-
-
Field Detail
-
selectionBackground
protected java.awt.Color selectionBackground
-
selectionForeground
protected java.awt.Color selectionForeground
-
selectionInactiveBackground
protected java.awt.Color selectionInactiveBackground
-
selectionInactiveForeground
protected java.awt.Color selectionInactiveForeground
-
selectionInsets
protected java.awt.Insets selectionInsets
- Since:
- 3
-
selectionArc
protected int selectionArc
- Since:
- 3
-
cellMargins
protected java.awt.Insets cellMargins
- Since:
- 2
-
cellFocusColor
protected java.awt.Color cellFocusColor
- Since:
- 2
-
showCellFocusIndicator
protected java.lang.Boolean showCellFocusIndicator
- Since:
- 2
-
oldStyleValues
private java.util.Map<java.lang.String,java.lang.Object> oldStyleValues
-
-
Method Detail
-
createUI
public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent c)
-
installUI
public void installUI(javax.swing.JComponent c)
- Overrides:
installUI
in classjavax.swing.plaf.basic.BasicListUI
-
installUIImpl
private void installUIImpl(javax.swing.JComponent c)
-
installDefaults
protected void installDefaults()
- Overrides:
installDefaults
in classjavax.swing.plaf.basic.BasicListUI
-
uninstallDefaults
protected void uninstallDefaults()
- Overrides:
uninstallDefaults
in classjavax.swing.plaf.basic.BasicListUI
-
createFocusListener
protected java.awt.event.FocusListener createFocusListener()
- Overrides:
createFocusListener
in classjavax.swing.plaf.basic.BasicListUI
-
createPropertyChangeListener
protected java.beans.PropertyChangeListener createPropertyChangeListener()
- Overrides:
createPropertyChangeListener
in classjavax.swing.plaf.basic.BasicListUI
-
createListSelectionListener
protected javax.swing.event.ListSelectionListener createListSelectionListener()
- Overrides:
createListSelectionListener
in classjavax.swing.plaf.basic.BasicListUI
-
installStyle
protected void installStyle()
- Since:
- 2
-
applyStyle
protected void applyStyle(java.lang.Object style)
- Since:
- 2
-
applyStyleProperty
protected java.lang.Object applyStyleProperty(java.lang.String key, java.lang.Object value)
- Since:
- 2
-
getStyleableInfos
public java.util.Map<java.lang.String,java.lang.Class<?>> getStyleableInfos(javax.swing.JComponent c)
- Specified by:
getStyleableInfos
in interfaceFlatStylingSupport.StyleableUI
- Since:
- 2
-
getStyleableValue
public java.lang.Object getStyleableValue(javax.swing.JComponent c, java.lang.String key)
- 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(java.awt.Graphics g, int row, java.awt.Rectangle rowBounds, javax.swing.ListCellRenderer cellRenderer, javax.swing.ListModel dataModel, javax.swing.ListSelectionModel selModel, int leadIndex)
- Overrides:
paintCell
in classjavax.swing.plaf.basic.BasicListUI
-
paintCellSelection
protected void paintCellSelection(java.awt.Graphics g, int row, int x, int y, int width, int height)
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(javax.swing.JList<?> list, java.awt.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
-
-