Last active
July 8, 2020 09:57
-
-
Save codenameone/7aa88182d6a7f63cbd4e to your computer and use it in GitHub Desktop.
Simple ComboBox sample that creates a combo box with a GenericListCellRenderer & MultiButton
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
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample usage of ComboBox.
From the Codename One project