Skip to content

Instantly share code, notes, and snippets.

@codenameone
Last active July 8, 2020 09:57
Show Gist options
  • Save codenameone/003d20de84f1a962b811 to your computer and use it in GitHub Desktop.
Save codenameone/003d20de84f1a962b811 to your computer and use it in GitHub Desktop.
A trivial sample of the list cell renderer in Codename One
class MyYesNoRenderer extends Label implements ListCellRenderer {
Label label = new Label(" ");
public Component getListCellRendererComponent(List list, Object value, int index, boolean isSelected) {
if( ((Boolean)value).booleanValue() ) {
setText("Yes");
} else {
setText("No");
}
return this;
}
public Component getListFocusComponent(List list) {
return label;
}
}
Form f = new Form("ListRenderer", new BorderLayout());
List<Boolean> lst = new List<Boolean>(Boolean.TRUE, Boolean.FALSE);
f.addComponent(BorderLayout.CENTER, lst);
f.show();
@codenameone
Copy link
Author

Sample usage code for ListCellRenderer.

From the Codename One project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment