Package org.jdesktop.swingx.renderer
Class DefaultTableRenderer
- java.lang.Object
-
- org.jdesktop.swingx.renderer.AbstractRenderer
-
- org.jdesktop.swingx.renderer.DefaultTableRenderer
-
- All Implemented Interfaces:
java.io.Serializable,javax.swing.table.TableCellRenderer,UIDependent,StringValue,RolloverRenderer
public class DefaultTableRenderer extends AbstractRenderer implements javax.swing.table.TableCellRenderer
Adapter to glue SwingX renderer support to core api. It has convenience constructors to create a LabelProvider, optionally configured with a StringValue and horizontal alignment. Typically, client code does not interact with this class except at instantiation time.JXTableuses 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()));- Author:
- Jeanette Winzenburg
- See Also:
ComponentProvider,LabelProvider,StringValue,IconValue,MappedValue,CellContext, Serialized Form
-
-
Field Summary
-
Fields inherited from class org.jdesktop.swingx.renderer.AbstractRenderer
componentController
-
-
Constructor Summary
Constructors Constructor 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 converter, int alignment)Instantiates a default table renderer with a default component provider using the given converter and horizontal alignment.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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ComponentProvider<?>createDefaultComponentProvider()The default ComponentProvider to use if no special.java.awt.ComponentgetTableCellRendererComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, boolean hasFocus, int row, int column)Returns a configured component, appropriate to render the given list cell.-
Methods inherited from class org.jdesktop.swingx.renderer.AbstractRenderer
doClick, getComponentProvider, getString, isEnabled, setBackground, setForeground, updateUI
-
-
-
-
Constructor Detail
-
DefaultTableRenderer
public DefaultTableRenderer()
Instantiates a default table renderer with the default component provider.- See Also:
DefaultTableRenderer(ComponentProvider)
-
DefaultTableRenderer
public DefaultTableRenderer(ComponentProvider<?> componentProvider)
Instantiates a default table renderer with the given component provider. If the controller is null, creates and uses a default. The default provider is of typeLabelProvider.- Parameters:
componentProvider- the provider of the configured component to use for cell rendering
-
DefaultTableRenderer
public DefaultTableRenderer(StringValue converter)
Instantiates a default table renderer with a default component provider using the given converter.- Parameters:
converter- the converter to use for mapping the content value to a String representation.- See Also:
DefaultTableRenderer(ComponentProvider)
-
DefaultTableRenderer
public DefaultTableRenderer(StringValue converter, int alignment)
Instantiates a default table renderer with a default component provider using the given converter and horizontal alignment.- Parameters:
converter- the converter to use for mapping the content value to a String representation.- See Also:
DefaultTableRenderer(ComponentProvider)
-
DefaultTableRenderer
public DefaultTableRenderer(StringValue stringValue, IconValue iconValue)
Intantiates a default table renderer with default component provider using both converters.- Parameters:
stringValue- the converter to use for the string representationiconValue- the converter to use for the icon representation
-
DefaultTableRenderer
public DefaultTableRenderer(StringValue stringValue, IconValue iconValue, int alignment)
Intantiates a default table renderer with default component provider using both converters and the given alignment.- Parameters:
stringValue- the converter to use for the string representationiconValue- the converter to use for the icon representationalignment- the rendering component's horizontal alignment
-
-
Method Detail
-
getTableCellRendererComponent
public java.awt.Component getTableCellRendererComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, boolean hasFocus, int row, int column)Returns a configured component, appropriate to render the given list cell.Note: The component's name is set to "Table.cellRenderer" for the sake of Synth-based LAFs.
- Specified by:
getTableCellRendererComponentin interfacejavax.swing.table.TableCellRenderer- Parameters:
table- theJTablevalue- 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 render- Returns:
- the default table cell renderer
-
createDefaultComponentProvider
protected ComponentProvider<?> createDefaultComponentProvider()
The default ComponentProvider to use if no special.- Specified by:
createDefaultComponentProviderin classAbstractRenderer- Returns:
- the default
ComponentProvider
-
-