When I add an array of action-objects (the class extends AbstractAction)
to a combo box, I do receive the action performed events, great!
But the combo box items show the long string of the action object, of course!
How to render that string in a way that only the Action.NAME appears?
I was experimenting a little, but could not make it to work:
Java Code:
private class ComboRenderer2 extends BasicComboBoxRenderer {
@Override
public Component getListCellRendererComponent(JList list,
Object value, int index, boolean isSelected,
boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index,
isSelected, cellHasFocus);
final Object fntObj = value;
Action sa = null;
sa = (Action) fntObj;
String s = (String) sa.getValue(Action.NAME);
// ??
return this;
}
}
No comments:
Post a Comment