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

public class LabelProvider
extends ComponentProvider<JLabel>

A component provider which uses a JLabel as rendering component.

It configures the Label's text and icon property from the StringValue.

See Also:
StringValue, FormatStringValue, IconValue, Serialized Form

Field Summary
 
Fields inherited from class org.jdesktop.swingx.renderer.ComponentProvider
alignment, defaultVisuals, formatter, rendererComponent
 
Constructor Summary
LabelProvider()
          Instantiates a LabelProvider with default to-String converter and LEADING horizontal alignment .
LabelProvider(int alignment)
          Instantiates a LabelProvider with default to-String converter and given horizontal alignment.
LabelProvider(StringValue converter)
          Instantiates a LabelProvider with the given to-String converter and LEADING horizontal alignment.
LabelProvider(StringValue converter, int alignment)
          Instantiates a LabelProvider with given to-String converter and given horizontal alignment.
 
Method Summary
protected  void configureState(CellContext context)
          Configures the renderering component's state from the given cell context.
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.
 
Methods inherited from class org.jdesktop.swingx.renderer.ComponentProvider
configureContent, configureVisuals, createDefaultVisuals, getDefaultVisuals, getHorizontalAlignment, getRendererComponent, getString, getStringValue, getValueAsIcon, getValueAsString, setHorizontalAlignment, setStringValue
 
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 LabelProvider with default to-String converter and LEADING horizontal alignment .


LabelProvider

public LabelProvider(StringValue converter)
Instantiates a LabelProvider with the given to-String converter and LEADING horizontal alignment. 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 LabelProvider with default to-String converter and given horizontal alignment.

Parameters:
alignment - the horizontal alignment.

LabelProvider

public LabelProvider(StringValue converter,
                     int alignment)
Instantiates a LabelProvider with given to-String converter and given horizontal alignment. 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.
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's text and icon property to the value as returned by getValueAsString/Icon, respectively.

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