Package org.jdesktop.swingx.renderer
Interface StringValue
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
AbstractRenderer
,DefaultListRenderer
,DefaultTableRenderer
,DefaultTreeRenderer
,FormatStringValue
,JXTree.DelegatingRenderer
,LocalizableStringValue
,MappedValue
,MappedValues.MappedValueUIResource
,StringValues.StringValueUIResource
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A simple converter to return a String representation of an object.
This class is intended to be the "small coin" to configure/format textual
cell content of concrete subclasses of
ComponentProvider
.
F.i. to show a Contributor cell object as "Busywoman, Herta" implement a custom StringValue and use it in a text rendering provider.
StringValue stringValue = (Object value) -> {
if(value instanceof Contributor c) {
return c.lastName + ", " + contributor.firstName;
}
return TO_STRING.getString(value);
};
ComponentProvider provider = new LabelProvider(stringValue);
table.setDefaultRenderer(Contributor.class, new DefaultTableRenderer(provider));
PENDING: use a full-fledged Format instead? Would impose a higher burden onto implementors but could be re-used in editors.
- Author:
- Jeanette Winzenburg
- See Also:
-
Method Summary
-
Method Details
-
getString
Returns a string representation of the given value.PENDING JW: forgot - why not null return guaranteed?
- Parameters:
value
- the object to present as a string- Returns:
- a string representation of the given value, guaranteed to be not null
-