java - ComboBox (setSelectedIndex()) is not working properly -


i have 7 items in combobox , every time when select 1 of them , click "next" button selects first item not next. knows why?

    if ("Цена (euro)".equals((string) combobox.getselecteditem())) {             if (!"".equals(txtarea.gettext().tostring())) {                 cenaeuroa = null;                 string data = (string) txtarea.gettext();                 string[] temp = data.split("\n");                 cenaeuroa = new string[temp.length];                 system.arraycopy(temp, 0, cenaeuroa, 0, temp.length);                 len = cenaeuroa.length;             }             combobox.setselectedindex(0); //            object sort = "СОРТ"; //            combobox.setselecteditem(sort);         }         txtarea.settext(null); 

you selecting first element, combobox.setselectedindex(0). should use getselectedindex() retrieve selected item , use set next.

for example:

final int selectedindex = combobox.getselectedindex(); if (selectedindex < combobox.getitemcount()) {     combobox.setselectedindex(selectedindex + 1);  } 

Comments

Popular posts from this blog

Winapi c++: DialogBox hangs when breaking a loop -

vb.net - Font adding using PDFsharp -

javascript - jQuery iScroll clickable list elements while retaining scroll? -