Class IconHighlighter
- All Implemented Interfaces:
Highlighter
Note: The limitation to JLabel icons (vs. covering AbstractButton as well) is intentional. Highlighters are allowed to touch only those properties of the rendering component which are guaranteed to be reset by the corresponding ComponentProvider, this implementation is safe enough - LabelProvider guarantees to reset both text and icon. On the other hand, CheckBoxProvider doesn't touch the icon (which is LAF depend), consequently this Highlighter must not touch it as well. Custom subclasses trying to cover AbstractButton must take care that their custom providers reset the icon property.
- Author:
- Jeanette Winzenburg
- See Also:
-
Field Summary
Fields inherited from class org.jdesktop.swingx.decorator.AbstractHighlighter
listenerList
-
Constructor Summary
ConstructorsConstructorDescriptionInstantiates a IconHighlighter with null Icon and default HighlightPredicate.IconHighlighter
(Icon icon) Instantiates a IconHighlighter with the specified Icon and default HighlightPredicate.IconHighlighter
(HighlightPredicate predicate) Instantiates a IconHighlighter with null Icon the given predicate.IconHighlighter
(HighlightPredicate predicate, Icon icon) Instantiates a IconHighlighter with the specified Icon and HighlightPredicate. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
canHighlight
(Component component, ComponentAdapter adapter) Subclasses may override to further limit the highlighting based on Highlighter state, f.i. a PainterHighlighter can only be applied to PainterAware components.protected Component
doHighlight
(Component component, ComponentAdapter adapter) Apply the highlights.getIcon()
Returns the Icon used for decoration.void
Sets the icon to use for decoration.Methods inherited from class org.jdesktop.swingx.decorator.AbstractHighlighter
addChangeListener, areEqual, fireStateChanged, getChangeListeners, getHighlightPredicate, highlight, removeChangeListener, setHighlightPredicate
-
Constructor Details
-
IconHighlighter
public IconHighlighter()Instantiates a IconHighlighter with null Icon and default HighlightPredicate. -
IconHighlighter
Instantiates a IconHighlighter with null Icon the given predicate.- Parameters:
predicate
- the HighlightPredicate to use.
-
IconHighlighter
Instantiates a IconHighlighter with the specified Icon and default HighlightPredicate.- Parameters:
icon
- the icon to use for decoration.
-
IconHighlighter
Instantiates a IconHighlighter with the specified Icon and HighlightPredicate.- Parameters:
predicate
- the HighlightPredicate to use.icon
- the Icon to use for decoration.
-
-
Method Details
-
setIcon
Sets the icon to use for decoration. A null icon indicates to not decorate.The default value is null.
- Parameters:
icon
- the Icon to use for decoration, might be null.
-
getIcon
Returns the Icon used for decoration.- Returns:
- icon the Icon used for decoration.
- See Also:
-
doHighlight
Apply the highlights. Implemented to set the component's Icon property, if possible and this Highlighter's icon is not null. Does nothing if the decorating icon is null.- Specified by:
doHighlight
in classAbstractHighlighter
- Parameters:
component
- the cell renderer component that is to be decoratedadapter
- the ComponentAdapter for this decorate operation- Returns:
- Component
component
- See Also:
-
canHighlight
Subclasses may override to further limit the highlighting based on Highlighter state, f.i. a PainterHighlighter can only be applied to PainterAware components.This implementation returns true always.
Overridden to return true if the component is of type IconAware or of type JLabel, false otherwise.
Note: special casing JLabel is for backward compatibility - application highlighting code which doesn't use the Swingx renderers would stop working otherwise.
- Overrides:
canHighlight
in classAbstractHighlighter
- Parameters:
component
- the cell renderer component that is to be decoratedadapter
- a Component Adapter- Returns:
- a boolean indication if the adapter can be highlighted based general state. This implementation returns true always.
-