Class CellRendererStateSupport
When creating a cell renderer that has more than one component to manage state of (such as a JLabel for
the icon, and a JTextArea for the text), this class can be used to coordinate the cell states so
that all the components are in sync: the correct background and foreground for the selected state, eg.
Handles the following renderer state of cells:
- Selected/Not Selected
- Enabled/Disabled
- Focused (see constructor for which components gets the focused border)
The following properties will be set for components supported by this class:
- Background
- Foreground
If the passed component is a JLabel and the label has a CellRendererIcon
For labels with no icons set in the initial state (the icon for these JLabels are null), use the
builder's addToIcons(JLabel).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic interface -
Method Summary
Modifier and TypeMethodDescriptionbuilder()builder(JComponent... components) voidupdate(boolean isSelected, boolean isEnabled, boolean hasFocus) voidupdate(boolean isSelected, boolean isEnabled, boolean hasFocus, List<CellRendererStateSupport.CellRendererStateComponent> components) Update the states of components in terms of background, foreground, and icon states.
-
Method Details
-
update
public void update(boolean isSelected, boolean isEnabled, boolean hasFocus) -
update
public void update(boolean isSelected, boolean isEnabled, boolean hasFocus, List<CellRendererStateSupport.CellRendererStateComponent> components) Update the states of components in terms of background, foreground, and icon states. UseaddToIcons(JLabel)to add components for which you wish the icon states to also be affected by the selected, or enabled state. -
getDisabledForeground
-
getDisabledBackground
-
getSelectedForeground
-
getSelectedBackground
-
getUnselectedForeground
-
getUnselectedBackground
-
builder
-
builder
- Parameters:
components-List of components for which the component states is to be managed by this class. If the component in the list is a
JLabeland that label containsCellRendererIcon, the icon state will be managed by this class.The first component in the list will serve as the component for which the focus border will be drawn.
-