Skip to content

Instantly share code, notes, and snippets.

@codenameone
Last active July 8, 2020 09:57
Show Gist options
  • Save codenameone/7aa88182d6a7f63cbd4e to your computer and use it in GitHub Desktop.
Save codenameone/7aa88182d6a7f63cbd4e to your computer and use it in GitHub Desktop.
Simple ComboBox sample that creates a combo box with a GenericListCellRenderer & MultiButton
public void showForm() {
Form hi = new Form("ComboBox", new BoxLayout(BoxLayout.Y_AXIS));
ComboBox<Map<String, Object>> combo = new ComboBox<> (
createListEntry("A Game of Thrones", "1996"),
createListEntry("A Clash Of Kings", "1998"),
createListEntry("A Storm Of Swords", "2000"),
createListEntry("A Feast For Crows", "2005"),
createListEntry("A Dance With Dragons", "2011"),
createListEntry("The Winds of Winter", "2016 (please, please, please)"),
createListEntry("A Dream of Spring", "Ugh"));
combo.setRenderer(new GenericListCellRenderer<>(new MultiButton(), new MultiButton()));
hi.show();
}
private Map<String, Object> createListEntry(String name, String date) {
Map<String, Object> entry = new HashMap<>();
entry.put("Line1", name);
entry.put("Line2", date);
return entry;
}
@codenameone
Copy link
Author

Sample usage of ComboBox.

From the Codename One project

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