org.jdesktop.swingx.decorator
Class IconHighlighter

java.lang.Object
  extended by org.jdesktop.swingx.decorator.AbstractHighlighter
      extended by org.jdesktop.swingx.decorator.IconHighlighter
All Implemented Interfaces:
Highlighter

public class IconHighlighter
extends AbstractHighlighter

Highlighter which decorates by setting the icon property of a label.


Field Summary
 
Fields inherited from class org.jdesktop.swingx.decorator.AbstractHighlighter
listenerList
 
Constructor Summary
IconHighlighter()
          Instantiates a IconHighlighter with null 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.
IconHighlighter(Icon icon)
          Instantiates a IconHighlighter with the specified Icon and default HighlightPredicate.
 
Method Summary
protected  boolean canHighlight(Component component, ComponentAdapter adapter)
          Subclasses may override to further limit the highlighting based on Highlighter state, f.i.
protected  Component doHighlight(Component component, ComponentAdapter adapter)
          Apply the highlights.
 Icon getIcon()
          Returns the Icon used for decoration.
 void setIcon(Icon icon)
          Sets the icon to use for decoration.
 
Methods inherited from class org.jdesktop.swingx.decorator.AbstractHighlighter
addChangeListener, areEqual, fireStateChanged, getChangeListeners, getHighlightPredicate, highlight, removeChangeListener, setHighlightPredicate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IconHighlighter

public IconHighlighter()
Instantiates a IconHighlighter with null Icon and default HighlightPredicate.


IconHighlighter

public IconHighlighter(HighlightPredicate predicate)
Instantiates a IconHighlighter with null Icon the given predicate.

Parameters:
predicate - the HighlightPredicate to use.

IconHighlighter

public IconHighlighter(Icon icon)
Instantiates a IconHighlighter with the specified Icon and default HighlightPredicate.

Parameters:
icon - the icon to use for decoration.

IconHighlighter

public IconHighlighter(HighlightPredicate predicate,
                       Icon icon)
Instantiates a IconHighlighter with the specified Icon and HighlightPredicate.

Parameters:
predicate - the HighlightPredicate to use.
icon - the Icon to use for decoration.
Method Detail

setIcon

public void setIcon(Icon icon)
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

public Icon getIcon()
Returns the Icon used for decoration.

Returns:
icon the Icon used for decoration.
See Also:
setIcon(Icon)

doHighlight

protected Component doHighlight(Component component,
                                ComponentAdapter adapter)
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 class AbstractHighlighter
Parameters:
component - the cell renderer component that is to be decorated
adapter - the ComponentAdapter for this decorate operation
See Also:
canHighlight(Component, ComponentAdapter), setIcon(Icon)

canHighlight

protected 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.

This implementation returns true always.

Overridden to return true if the component is of type JLabel, false otherwise.

Overrides:
canHighlight in class AbstractHighlighter
Returns:
a boolean indication if the adapter can be highlighted based general state. This implementation returns true always.