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

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -