dsto.dfc.swing.controls
Class AbstractCellRenderer

java.lang.Object
  extended by dsto.dfc.swing.controls.AbstractCellRenderer
All Implemented Interfaces:
CellRenderer, ListCellRenderer, TableCellRenderer, TreeCellRenderer
Direct Known Subclasses:
ColorCellRenderer, FontCellRenderer, IconicCellRenderer

public abstract class AbstractCellRenderer
extends Object
implements CellRenderer

Base for classes that want to implement a cell renderer that can be used interchangably for lists, tables and trees: classes implement one method (getRendererComponent ()) to provide a renderer for all 3 interfaces. Provides support for setting colours, borders etc based on behaviour of default renderers.

Version:
$Revision$

Constructor Summary
AbstractCellRenderer()
           
 
Method Summary
 Color getBackground()
          The current background colour that should be used.
 Border getBorder()
          The current border that should be used.
 Color getForeground()
          The current foreground colour that should be used.
 JLabel getLabel()
          Get a label guaranteed to have correct colours and borders set.
 Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean hasFocus)
           
abstract  JComponent getRendererComponent(JComponent client, Object value, int row, int column, boolean isSelected, boolean hasFocus, boolean expanded, boolean leaf)
          Return the renderer component.
 Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
           
 Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCellRenderer

public AbstractCellRenderer()
Method Detail

getBackground

public Color getBackground()
The current background colour that should be used.


getForeground

public Color getForeground()
The current foreground colour that should be used.


getBorder

public Border getBorder()
The current border that should be used.


getLabel

public JLabel getLabel()
Get a label guaranteed to have correct colours and borders set.


getRendererComponent

public abstract JComponent getRendererComponent(JComponent client,
                                                Object value,
                                                int row,
                                                int column,
                                                boolean isSelected,
                                                boolean hasFocus,
                                                boolean expanded,
                                                boolean leaf)
Return the renderer component.

Specified by:
getRendererComponent in interface CellRenderer

getTreeCellRendererComponent

public Component getTreeCellRendererComponent(JTree tree,
                                              Object value,
                                              boolean selected,
                                              boolean expanded,
                                              boolean leaf,
                                              int row,
                                              boolean hasFocus)
Specified by:
getTreeCellRendererComponent in interface TreeCellRenderer

getTableCellRendererComponent

public Component getTableCellRendererComponent(JTable table,
                                               Object value,
                                               boolean isSelected,
                                               boolean hasFocus,
                                               int row,
                                               int column)
Specified by:
getTableCellRendererComponent in interface TableCellRenderer

getListCellRendererComponent

public Component getListCellRendererComponent(JList list,
                                              Object value,
                                              int index,
                                              boolean isSelected,
                                              boolean hasFocus)
Specified by:
getListCellRendererComponent in interface ListCellRenderer


Copyright © 2008 Commonwealth of Australia