swing - JComboBox - Unable to get the value -


i've created jcombobox in table per below.

code

          tablecolumn col5 = jtable1.getcolumnmodel().getcolumn(4);                 string[] options = new string[]{"font issue","text issue","image issue","ai issue","others"};           jcombobox combo1 = new jcombobox(options);           jcombobox combo2 = new jcombobox(options);           col5.setcelleditor(new defaultcelleditor(combo1));           col5.setcellrenderer(new comboboxrenderer(combo2));           col5.setpreferredwidth(150);           combo2.addactionlistener(new actionlistener() {             public void actionperformed(actionevent e) {                                 string dropdownvalue = col5.getcelleditor().getcelleditorvalue().tostring();                 if(dropdownvalue.equalsignorecase("others"))                 {                     joptionpane.showmessagedialog(null, "alert", "alert", "");                 }             }         }); 

there error when try dropwon value.

error

local variable col5 accessed within inner class; needs declared final.

i tried this.

string dropdownvalue = combo1.getselecteditem().tostring(); 

but similiar error

local variable combo1 accessed within inner class; needs declared final 

please help. thanks

change

 tablecolumn col5 = jtable1.getcolumnmodel().getcolumn(4);  

to

 final tablecolumn col5 = jtable1.getcolumnmodel().getcolumn(4);  

you defining anonymous class. avoid strange side-effects closures in java variables must marked final.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -