swing - java DefaultListModel -


if(incasationbegin > 0) {   int anwser = joptionpane.showconfirmdialog(null, config.question,"confirm", joptionpane.yes_no_option);   if(anwser == 1)   {       jlist0.setselectedindex(incasationbegin);       return;   } } incasationbegin = jlist0.getselectedindex(); 

how setselectedindex without calling jlist0listselectionvaluechanged action? because when click on option confirm popup , when click no, new item still selected. have tried add incasationbegin =0; before return, on first click confirm popup.

let me see if understood correctly. adding listselectionlistener jlist , want prevent call setselectedindex firing valuechanged event, it?

you can try lot of different approaches here:

  1. delay call jlist0.addlistselectionlistener(... in such way no listener exists when call setselectedindex.
  2. have listener valuechanged method check "enabled condition", example read boolean isenabled. set condition false before calling setselectedindex , true after that.
  3. call jlist0.removelistselectionlistener(.. before call setselectedindex. add listener list again after call.

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -