org.jdesktop.swingx.renderer
Class LabelProvider

java.lang.Object
  extended by org.jdesktop.swingx.renderer.ComponentProvider<JLabel>
      extended by org.jdesktop.swingx.renderer.LabelProvider
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
TreeLabelProvider

public class LabelProvider
extends ComponentProvider<JLabel>

A component provider which uses a JLabel.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jdesktop.swingx.renderer.ComponentProvider
alignment, defaultVisuals, formatter, rendererComponent
 
Constructor Summary
LabelProvider()
          Instantiates a default component provider with LEADING horizontal alignment and default to-String converter.
LabelProvider(int alignment)
          Instantiates a default component provider with the given horizontal alignment and default to-String converter.
LabelProvider(StringValue converter)
          Instantiates a default component provider with LEADING horizontal alignment and the given to-String converter.
 
Method Summary
protected  void configureState(CellContext context)
          Configures the renderering component's state from the given cell context. Here: sets the Label's horizontal alignment to the alignment as configured in the controller.
protected  JLabel createRendererComponent()
          Factory method to create and return the component to use for rendering.
protected  void format(CellContext context)
          Formats the renderering component's content from the given cell context. Here: sets the labels text and icon property depending on the type of the context's value.
 
Methods inherited from class org.jdesktop.swingx.renderer.ComponentProvider
configureContent, configureVisuals, createRendererController, getHorizontalAlignment, getRendererComponent, getRendererController, getStringValue, getToStringConverter, setHorizontalAlignment, setToStringConverter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LabelProvider

public LabelProvider()
Instantiates a default component provider with LEADING horizontal alignment and default to-String converter.


LabelProvider

public LabelProvider(StringValue converter)
Instantiates a default component provider with LEADING horizontal alignment and the given to-String converter. If the converter is null, the default TO_STRING is used.

Parameters:
converter - the converter to use for mapping the cell value to a String representation.

LabelProvider

public LabelProvider(int alignment)
Instantiates a default component provider with the given horizontal alignment and default to-String converter.

Parameters:
alignment - the horizontal alignment.
Method Detail

createRendererComponent

protected JLabel createRendererComponent()
Factory method to create and return the component to use for rendering.

Specified by:
createRendererComponent in class ComponentProvider<JLabel>
Returns:
the component to use for rendering.

configureState

protected void configureState(CellContext context)
Configures the renderering component's state from the given cell context. Here: sets the Label's horizontal alignment to the alignment as configured in the controller.

Specified by:
configureState in class ComponentProvider<JLabel>
Parameters:
context - the cell context to configure from, must not be null.

format

protected void format(CellContext context)
Formats the renderering component's content from the given cell context. Here: sets the labels text and icon property depending on the type of the context's value. If the value is of Icon type, it's used as the label's icon and the text is set to empty. Otherwise, the icon is set to null and the text is set to the value as returned from getStringValue.

Note: this is the behaviour as implemented in core default list renderer. It is different from core default table renderer which handles icons in a subclass only.

Specified by:
format in class ComponentProvider<JLabel>
Parameters:
context - the cellContext to use
See Also:
ComponentProvider.getStringValue(CellContext)