jcombobox - sorting java combobox items -
i'm trying names , ids database , add them combobox. i've added checkcombobox project;
by of code; https://stackoverflow.com/a/17097767
resultset resultset= "here getting result set query having order clause while (resultset.next()) { int id = resultset.getint(1); string name = resultset.getstring(2); system.out.println(name); options.add(new option<integer>(name, id)); } system.out.println gives output sorted name items in checkcombobox not sorted. how can add items sorted in combobox?
- don't use
setconstructor, usecheckcombobox(map<object, boolean> mapobjselected)constructor. - use
treemap.setconstructor createslinkedhashmapdefault, doesn't preserve order. - properly implement
comparetomethod in codeoption. may need add field telloptions order they're supposed in.
Comments
Post a Comment