7

i'm using lwuit with j2me . how to get combo box selected item or index? i found the function for setSelectedIndex but not for getting the selected.

ArK
  • 20,698
  • 67
  • 109
  • 136

2 Answers2

23

Use this code :

comboBox.getSelectionModel().getSelectedIndex(); 

To return the current selected offset in the list.

comboBox.getSelectionModel().getSelectedItem(); 

To return the current selected item in the list or null for no selection

Community
  • 1
  • 1
bharath
  • 14,283
  • 16
  • 57
  • 95
  • thanks bharath. may i know the citation please. because i'm very much struggle to find the documentation – ArK Jul 27 '11 at 05:21
  • @Paniyar: look at here, [LWUIT Java documentation.](http://lwuit.java.net/nonav/javadocs/index.html). – bharath Jul 27 '11 at 05:25
3

To get what you selected as a string:

String selected_text = ComboBox.getItemAt(ComboBox.getSelectedIndex());
Haig Simci
  • 51
  • 5