ArK
ArK

Reputation: 21076

how to get selected item of combo box

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.

Upvotes: 7

Views: 84469

Answers (2)

bharath
bharath

Reputation: 14473

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

Upvotes: 23

Haig Simci
Haig Simci

Reputation: 51

To get what you selected as a string:

String selected_text = ComboBox.getItemAt(ComboBox.getSelectedIndex());

Upvotes: 3

Related Questions