swingx
Version 2005-08-19

org.jdesktop.swingx.decorator
Class AlternateRowHighlighter

java.lang.Object
  extended by org.jdesktop.swingx.decorator.Highlighter
      extended by org.jdesktop.swingx.decorator.AlternateRowHighlighter
Direct Known Subclasses:
AlternateRowHighlighter.UIAlternateRowHighlighter

public class AlternateRowHighlighter
extends Highlighter

AlternateRowHighlighter prepares a cell renderer to use different background colors for alternating rows in a data view. The size (in terms of row count) of an alternating group is configurable (defaults to 1);


Nested Class Summary
static class AlternateRowHighlighter.UIAlternateRowHighlighter
           
 
Nested classes/interfaces inherited from class org.jdesktop.swingx.decorator.Highlighter
Highlighter.UIHighlighter
 
Field Summary
static Highlighter beige
           
static Highlighter classicLinePrinter
           
static Highlighter floralWhite
           
static AlternateRowHighlighter genericGrey
           
static Highlighter linePrinter
           
static Highlighter quickSilver
           
 
Fields inherited from class org.jdesktop.swingx.decorator.Highlighter
changeEvent, immutable, ledgerBackground, listenerList, notePadBackground
 
Constructor Summary
AlternateRowHighlighter()
          Constructs a default AlternateRowHighlighter that prepares a cell renderer to paint a white background for odd rows and a silver (0xF0, 0xF0, 0xE0) background for even rows.
AlternateRowHighlighter(Color oddRowBackground, Color evenRowBackground, Color foreground)
          Constructs an AlternateRowHighlighter that prepares a cell renderer to paint the specified background colors for odd and even and even rows.
AlternateRowHighlighter(Color oddRowBackground, Color evenRowBackground, Color foreground, boolean immutable)
           
 
Method Summary
protected  Color computeUnselectedBackground(Component renderer, ComponentAdapter adapter)
          Computes a suitable unselected background for the renderer component within the specified adapter and returns the computed color.
 Color getEvenRowBackground()
          Returns the background color for even rows, or null if the background color of the cell renderer should be left unchanged for even rows.
 int getLinesPerGroup()
           
 Color getOddRowBackground()
          Returns the background color for odd rows, or null if the background color of the cell renderer should be left unchanged for odd rows.
protected  boolean isOddRow(ComponentAdapter adapter)
           
 void setEvenRowBackground(Color color)
          Sets the background color for even rows to the specified color.
 void setLinesPerGroup(int linesPerGroup)
           
 void setOddRowBackground(Color color)
          Sets the background color for odd rows to the specified color.
 
Methods inherited from class org.jdesktop.swingx.decorator.Highlighter
addChangeListener, applyBackground, applyForeground, computeBackground, computeForeground, computeSelectedBackground, computeSelectedBackground, computeSelectedForeground, computeSelectedForeground, computeUnselectedForeground, doHighlight, fireStateChanged, getBackground, getChangeListeners, getForeground, getSelectedBackground, getSelectedForeground, highlight, isImmutable, removeChangeListener, setBackground, setForeground, setSelectedBackground, setSelectedForeground
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

beige

public static final Highlighter beige

linePrinter

public static final Highlighter linePrinter

classicLinePrinter

public static final Highlighter classicLinePrinter

floralWhite

public static final Highlighter floralWhite

quickSilver

public static final Highlighter quickSilver

genericGrey

public static final AlternateRowHighlighter genericGrey
Constructor Detail

AlternateRowHighlighter

public AlternateRowHighlighter()
Constructs a default AlternateRowHighlighter that prepares a cell renderer to paint a white background for odd rows and a silver (0xF0, 0xF0, 0xE0) background for even rows.


AlternateRowHighlighter

public AlternateRowHighlighter(Color oddRowBackground,
                               Color evenRowBackground,
                               Color foreground)
Constructs an AlternateRowHighlighter that prepares a cell renderer to paint the specified background colors for odd and even and even rows. A foreground color may also be specified. If null is specified for the foreground color, the foreground color for the renderer is unchanged. Otherwise, it is set to the specified foreground color for both odd and even rows.

Parameters:
oddRowBackground -
evenRowBackground -
foreground -

AlternateRowHighlighter

public AlternateRowHighlighter(Color oddRowBackground,
                               Color evenRowBackground,
                               Color foreground,
                               boolean immutable)
Method Detail

getOddRowBackground

public Color getOddRowBackground()
Returns the background color for odd rows, or null if the background color of the cell renderer should be left unchanged for odd rows.

Returns:
the background color for odd rows, or null if the background color of the cell renderer should be left unchanged for odd rows

setOddRowBackground

public void setOddRowBackground(Color color)
Sets the background color for odd rows to the specified color. If null is specified, the background color for odd rows is left unchanged in the renderer

Parameters:
color - the background color for odd rows, or null if the background color of the cell renderer should be left unchanged for odd rows

getEvenRowBackground

public Color getEvenRowBackground()
Returns the background color for even rows, or null if the background color of the cell renderer should be left unchanged for even rows.

Returns:
the background color for even rows, or null if the background color of the cell renderer should be left unchanged for even rows

setEvenRowBackground

public void setEvenRowBackground(Color color)
Sets the background color for even rows to the specified color. If null is specified, the background color for even rows is left unchanged in the renderer.

Parameters:
color - the background color for even rows, or null if the background color of the cell renderer should be left unchanged for even rows

computeUnselectedBackground

protected Color computeUnselectedBackground(Component renderer,
                                            ComponentAdapter adapter)
Description copied from class: Highlighter

Computes a suitable unselected background for the renderer component within the specified adapter and returns the computed color. This implementation returns getBackground().

Overrides:
computeUnselectedBackground in class Highlighter
Returns:
unselected background color

isOddRow

protected boolean isOddRow(ComponentAdapter adapter)
Parameters:
adapter -
Returns:
true if the adapter's row should be colored with the oddRowBackground, false is not

getLinesPerGroup

public int getLinesPerGroup()

setLinesPerGroup

public void setLinesPerGroup(int linesPerGroup)

swingx
Version 2005-08-19