i have problem while learning java using netbean in java ui.
have string list called listto
. have comboboxmodel
contains object. have textarea
variable name to
, , have button. if click button text area this
" " <- first
second time click button this
"a , b "
, on every time click button.
here's code:
contact = listcon.get(cbcon.getselectedindex() - 1); listto.add(contact.getnamacontact()); (int = 0; < listto.size(); i++) { if(i==listto.size()-1){ to.settext(listto.get(i)); } else{ to.settext(listto.get(i)+", "); } }
when click button text area shows last of list.
example when first click button text area "a", , second time text area "b" not "a, b" how text area show of list items have?
don't use settext().
instead can use append(...)
method of jtextarea
append text existing text.