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.ColoralternateRowColorprotected java.awt.ColorcellFocusColorprotected java.awt.InsetscellMarginsprivate java.util.Map<java.lang.String,java.lang.Object>oldStyleValuesprotected intselectionArcprotected java.awt.ColorselectionBackgroundprotected java.awt.ColorselectionForegroundprotected java.awt.ColorselectionInactiveBackgroundprotected java.awt.ColorselectionInactiveForegroundprotected java.awt.InsetsselectionInsetsprotected java.lang.BooleanshowCellFocusIndicator-
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 voidapplyStyle(java.lang.Object style)protected java.lang.ObjectapplyStyleProperty(java.lang.String key, java.lang.Object value)protected java.awt.event.FocusListenercreateFocusListener()protected javax.swing.event.ListSelectionListenercreateListSelectionListener()protected java.beans.PropertyChangeListenercreatePropertyChangeListener()static javax.swing.plaf.ComponentUIcreateUI(javax.swing.JComponent c)java.util.Map<java.lang.String,java.lang.Class<?>>getStyleableInfos(javax.swing.JComponent c)java.lang.ObjectgetStyleableValue(javax.swing.JComponent c, java.lang.String key)protected voidinstallDefaults()protected voidinstallStyle()voidinstallUI(javax.swing.JComponent c)private voidinstallUIImpl(javax.swing.JComponent c)protected voidpaintCell(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 voidpaintCellSelection(java.awt.Graphics g, int row, int x, int y, int width, int height)Paints (rounded) cell selection.static voidpaintCellSelection(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 voidtoggleSelectionColors()Toggle selection colors from focused to inactive and vice versa.protected voiduninstallDefaults()private booleanuseUnitedRoundedSelection(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
-
alternateRowColor
protected java.awt.Color alternateRowColor
- Since:
- 3.6
-
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:
installUIin classjavax.swing.plaf.basic.BasicListUI
-
installUIImpl
private void installUIImpl(javax.swing.JComponent c)
-
installDefaults
protected void installDefaults()
- Overrides:
installDefaultsin classjavax.swing.plaf.basic.BasicListUI
-
uninstallDefaults
protected void uninstallDefaults()
- Overrides:
uninstallDefaultsin classjavax.swing.plaf.basic.BasicListUI
-
createFocusListener
protected java.awt.event.FocusListener createFocusListener()
- Overrides:
createFocusListenerin classjavax.swing.plaf.basic.BasicListUI
-
createPropertyChangeListener
protected java.beans.PropertyChangeListener createPropertyChangeListener()
- Overrides:
createPropertyChangeListenerin classjavax.swing.plaf.basic.BasicListUI
-
createListSelectionListener
protected javax.swing.event.ListSelectionListener createListSelectionListener()
- Overrides:
createListSelectionListenerin 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:
getStyleableInfosin interfaceFlatStylingSupport.StyleableUI- Since:
- 2
-
getStyleableValue
public java.lang.Object getStyleableValue(javax.swing.JComponent c, java.lang.String key)- Specified by:
getStyleableValuein 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:
paintCellin 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. SupportsselectionArcandselectionInsets.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
selectionArcandselectionInsets.- Since:
- 3
-
-