org.jdesktop.swing.decorator
Class AlternateRowHighlighter

java.lang.Object
  extended byorg.jdesktop.swing.decorator.Highlighter
      extended byorg.jdesktop.swing.decorator.AlternateRowHighlighter

public class AlternateRowHighlighter
extends Highlighter

AlternateRowHighlighter prepares a cell renderer to use different background colors for alternating rows in a data view.


Field Summary
static Highlighter beige
           
static Highlighter classicLinePrinter
           
protected  Color evenRowBackground
           
static Highlighter floralWhite
           
static Highlighter linePrinter
           
protected  Color oddRowBackground
           
static Highlighter quickSilver
           
 
Fields inherited from class org.jdesktop.swing.decorator.Highlighter
background, foreground, ledgerBackground, notePadBackground, order, selectedBackground, selectedForeground
 
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.
 
Method Summary
protected  Color computeBackground(Component renderer, ComponentAdapter adapter)
          Computes the background color for the current rendering context for the specified adapter.
 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.
 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.
 void setEvenRowBackground(Color color)
          Sets the background color for even rows to the specified color.
 void setOddRowBackground(Color color)
          Sets the background color for odd rows to the specified color.
 
Methods inherited from class org.jdesktop.swing.decorator.Highlighter
applyBackground, applyFont, applyForeground, computeForeground, computeSelectedBackground, computeSelectedForeground, doHighlight, getBackground, getForeground, getSelectedBackground, getSelectedForeground, highlight, 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

oddRowBackground

protected Color oddRowBackground

evenRowBackground

protected Color evenRowBackground
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 -
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

computeBackground

protected Color computeBackground(Component renderer,
                                  ComponentAdapter adapter)
Computes the background color for the current rendering context for the specified adapter. It first chooses the raw background color for the renderer depending on whether the row being rendered is odd or even. If the chosen background color is not null calls computeSelectedBackground passing in the chosen raw background color as the seed color, but only if the row being rendered is selected.

Overrides:
computeBackground in class Highlighter
Parameters:
renderer - the cell renderer component
adapter -
Returns:
the computed background color


Copyright 2004 by Sun Microsystems, Inc. All Rights Reserved.