This implementation respects a BooleanValue and a StringValue to configure the button's selected and text property. By default, the selected is mapped to a Boolean-type value and the text is empty.
To allow mapping to different types, client code can supply a custom StringValue which also implements BooleanValue. F.i. to render a cell value of type TableColumnExt with the column's visibility mapped to the selected and the column's title to the text:
BooleanValue bv = new BooleanValue(){ public boolean getBoolean(Object value) { if (value instanceof TableColumnExt) return ((TableColumnExt) value).isVisible(); return false; } }; StringValue sv = new StringValue() { public String getString(Object value) { if (value instanceof TableColumnExt) return ((TableColumnExt) value).getTitle(); return ""; } }; list.setCellRenderer(new DefaultListRenderer( new CheckBoxProvider(new MappedValue(sv, null, bv), JLabel.LEADING)));
@see BooleanValue
@see StringValue
@see MappedValue
@author Jeanette Winzenburg
|
|