java - Problems loading data into combobox -
public void muestraregistro(jtextfield t1 ,jtextfield t2 , jtextfield t3 , jtextfield t4 , jtextfield t5,jtextfield t6 , jcombobox cmb) { try { int row = productogui.tbldetalle.getselectedrow(); string muestra = productogui.tbldetalle.getmodel().getvalueat(row, 0).tostring(); //string muestra = productogui.tbldetalle.getvalueat(productogui.tbldetalle.getselectedrow(), 0).tostring(); rs = cargaregistro(); while (rs.next()) { t1.settext(rs.getstring(1)); t2.settext(rs.getstring(2)); cmb.setselecteditem(rs.getstring(3)); system.out.print(cmb); t3.settext(rs.getstring(4)); t4.settext(rs.getstring(5)); t5.settext(rs.getstring(6)); t6.settext(rs.getstring(7)); habilitatexto(false, t2, t3, t4, t5, t6); } } catch (sqlexception | headlessexception ex) { joptionpane.showmessagedialog(null,ex); logger.getlogger(productodao.class.getname()).log(level.severe, null, ex); } }
i have code, have trouble throws me following message when loading data combobox jtable
javax.swing.jcombobox[,113,91,200x18,layout=com.sun.java.swing.plaf.windows.windowscomboboxui$3,alignmentx=0.0,alignmenty=0.0,border=,flags=328,maximumsize=,minimumsize=,preferredsize=,iseditable=false,lightweightpopupenabled=true,maximumrowcount=8,selecteditemreminder=1]javax.swing.jcombobox[,113,91,200x18,layout=com.sun.java.swing.plaf.windows.windowscomboboxui$3,alignmentx=0.0,alignmenty=0.0,border=,flags=328,maximumsize=,minimumsize=,preferredsize=,iseditable=false,lightweightpopupenabled=true,maximumrowcount=8,selecteditemreminder=1]javax.swing.jcombobox[,113,91,200x18,layout=com.sun.java.swing.plaf.windows.windowscomboboxui$3,alignmentx=0.0,alignmenty=0.0,border=,flags=328,maximumsize=,minimumsize=,preferredsize=,iseditable=false,lightweightpopupenabled=true,maximumrowcount=8,selecteditemreminder=1]
this simple example shows combo box combo box model containing 3 strings. println
prints string cmb.getselectedindex(): 1
on laptop (which corresponds second string in model).
final jcombobox<string> cmb = new jcombobox<>(new string[]{"123", "456", "789"}); cmb.setselecteditem("456"); system.out.println("cmb.getselectedindex(): " + cmb.getselectedindex());
Comments
Post a Comment