public class SmartRenderer extends Object implements ListCellRenderer<Object>, TableCellRenderer, TreeCellRenderer
Class that knows how to render lots of things. If you want to create a renderer, just subclass this SmartRenderer and override the getStringValue() method. For any object that is not a known type toString is used. Null values are always displayed as "NULL". This class counts on the fact that the default renderers for list, trable and tree all return a subclass of JLabel. If that ever changes, this class breaks.
Known types
Constructor and Description |
---|
SmartRenderer() |
Modifier and Type | Method and Description |
---|---|
Component |
getListCellRendererComponent(JList<?> list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus) |
String |
getStringValue(Object value)
Get the string representation of this object.
|
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) |
public final Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus)
getListCellRendererComponent
in interface ListCellRenderer<Object>
public final Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
getTableCellRendererComponent
in interface TableCellRenderer
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)
getTreeCellRendererComponent
in interface TreeCellRenderer