public class DefaultTableRenderer extends AbstractRenderer implements TableCellRenderer
JXTable
uses instances of this as per-class default renderers.
setDefaultRenderer(Object.class, new DefaultTableRenderer());
setDefaultRenderer(Number.class, new DefaultTableRenderer(
FormatStringValues.NUMBER_TO_STRING, JLabel.RIGHT));
setDefaultRenderer(Date.class, new DefaultTableRenderer(
FormatStringValues.DATE_TO_STRING));
// use the same center aligned default for Image/Icon
TableCellRenderer renderer = new DefaultTableRenderer(new MappedValue(
StringValues.EMPTY, IconValues.ICON), JLabel.CENTER);
setDefaultRenderer(Icon.class, renderer);
setDefaultRenderer(ImageIcon.class, renderer);
// use a CheckBoxProvider for booleans
setDefaultRenderer(Boolean.class,
new DefaultTableRenderer(new CheckBoxProvider()));
ComponentProvider
,
LabelProvider
,
StringValue
,
IconValue
,
MappedValue
,
CellContext
,
Serialized FormModifier and Type | Field and Description |
---|---|
private TableCellContext |
cellContext |
componentController
Constructor and Description |
---|
DefaultTableRenderer()
Instantiates a default table renderer with the default component
provider.
|
DefaultTableRenderer(ComponentProvider<?> componentProvider)
Instantiates a default table renderer with the given component provider.
|
DefaultTableRenderer(StringValue converter)
Instantiates a default table renderer with a default component
provider using the given converter.
|
DefaultTableRenderer(StringValue stringValue,
IconValue iconValue)
Intantiates a default table renderer with default component provider
using both converters.
|
DefaultTableRenderer(StringValue stringValue,
IconValue iconValue,
int alignment)
Intantiates a default table renderer with default component provider
using both converters and the given alignment.
|
DefaultTableRenderer(StringValue converter,
int alignment)
Instantiates a default table renderer with a default component
provider using the given converter and horizontal
alignment.
|
Modifier and Type | Method and Description |
---|---|
protected ComponentProvider<?> |
createDefaultComponentProvider()
The default ComponentProvider to use if no special.
|
Component |
getTableCellRendererComponent(JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column)
Returns a configured component, appropriate to render the given
list cell.
|
doClick, getComponentProvider, getString, isEnabled, setBackground, setForeground, updateUI
private TableCellContext cellContext
public DefaultTableRenderer()
DefaultTableRenderer(ComponentProvider)
public DefaultTableRenderer(ComponentProvider<?> componentProvider)
LabelProvider
.componentProvider
- the provider of the configured component to
use for cell renderingpublic DefaultTableRenderer(StringValue converter)
converter
- the converter to use for mapping the
content value to a String representation.DefaultTableRenderer(ComponentProvider)
public DefaultTableRenderer(StringValue converter, int alignment)
converter
- the converter to use for mapping the
content value to a String representation.DefaultTableRenderer(ComponentProvider)
public DefaultTableRenderer(StringValue stringValue, IconValue iconValue)
stringValue
- the converter to use for the string representationiconValue
- the converter to use for the icon representationpublic DefaultTableRenderer(StringValue stringValue, IconValue iconValue, int alignment)
stringValue
- the converter to use for the string representationiconValue
- the converter to use for the icon representationalignment
- the rendering component's horizontal alignmentpublic Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
Note: The component's name is set to "Table.cellRenderer" for the sake of Synth-based LAFs.
getTableCellRendererComponent
in interface TableCellRenderer
table
- the JTable
value
- the value to assign to the cell at
[row, column]
isSelected
- true if cell is selectedhasFocus
- true if cell has focusrow
- the row of the cell to rendercolumn
- the column of the cell to renderprotected ComponentProvider<?> createDefaultComponentProvider()
createDefaultComponentProvider
in class AbstractRenderer
ComponentProvider
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses