java - Adding list item to JList from another JList -
i have following code working
made_list.setlistdata(original_list.getselectedvalues());
here made_list 1 jlist , original_list jlist. if run code selected value original_list replacing previous value in made_list. dont want that. want append instead.. how do ??
1) model made_list 2) selected items orig_list 3) make new object[] size of 1) + 2) 4) populate 3) items 1) + 2) 5) set make_list model object[] 4)
implementation:
listmodel made_model = made_list.getmodel(); // 1 object[] orig_sel = orig_list.getselecteditems(); // 2 object[] new_made_model = new object[made_model.size() + orig_sel.length]; // 3 // block 4 int = 0; for(;i < made_model.size(); i++) new_made_model[i] = made_model.getelementat(i); for(; < new_made_model.length; i++) new_made_model[i] = orig_sel[i - made_model.size()); made_model.setlistdata(new_made_model); // 5
Comments
Post a Comment