Last active
July 8, 2020 09:57
-
-
Save codenameone/003d20de84f1a962b811 to your computer and use it in GitHub Desktop.
A trivial sample of the list cell renderer in Codename One
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample usage code for ListCellRenderer.
From the Codename One project