Skip to content

Commit

Permalink
using ContributorCellRenderer merit Highlighter does not work
Browse files Browse the repository at this point in the history
  • Loading branch information
homebeaver committed Dec 30, 2022
1 parent 20d86ec commit d39c277
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/main/java/org/jdesktop/swingx/demos/xlist/XListDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import org.jdesktop.swingx.demos.svg.CircleFlagZA;
import org.jdesktop.swingx.icon.SizingConstants;
import org.jdesktop.swingx.painter.MattePainter;
import org.jdesktop.swingx.renderer.DefaultListRenderer;
import org.jdesktop.swingx.renderer.IconValue;
import org.jdesktop.swingx.renderer.StringValue;
import org.jdesktop.swingx.renderer.StringValues;
Expand Down Expand Up @@ -243,7 +244,22 @@ public XListDemo(Frame frame) {

// configureComponents:
// <snip> JXList rendering
list.setCellRenderer(new ContributorCellRenderer());
// custom String representation: concat various element fields
StringValue sv = new StringValue() {

@Override
public String getString(Object value) {
if (value instanceof Contributor) {
Contributor c = (Contributor) value;
return c.getFirstName() + " " + c.getLastName() + " (" + c.getMerits() + ")";
}
return StringValues.TO_STRING.getString(value);
}

};
list.setCellRenderer(new DefaultListRenderer<Contributor>(sv));
// BUG: when using ContributorCellRenderer merit Highlighter does not work !!! TODO
// list.setCellRenderer(new ContributorCellRenderer());

// Set the preferred row count. This affects the preferredSize of the JList when it's in a scrollpane.
// In HORIZONTAL_WRAP and VERTICAL_WRAP orientations affects how cells are wrapped.
Expand Down

0 comments on commit d39c277

Please sign in to comment.