mysterious Jlist behaviour (valuechanged)

W

wnstnsmith

Dear all,

Every time I klick in a Jlist to change its value, it turns out
valueChanged() is called twice, both times with the new seleceted index
value. I am not doubleclicking inadvertently.
I don't like it, because alle the work that is to be done on changing the
selected value is carried out twice as well, of course. Does anybody know
why two valauechanged events are sent and how I can get rid of this
behaviour?

tia,

Winston
 
L

Lee Weiner

Dear all,

Every time I klick in a Jlist to change its value, it turns out
valueChanged() is called twice, both times with the new seleceted index
value. I am not doubleclicking inadvertently.
I don't like it, because alle the work that is to be done on changing the
selected value is carried out twice as well, of course. Does anybody know
why two valauechanged events are sent and how I can get rid of this
behaviour?

tia,

Winston

I don't know if you can get rid of this behavior, but you can deal with it.
In the valueChanged() method, there is a ListSelectionEvent object available,
which contains a getValueIsAdjusting() method. Call this method and, if it
returns true, do not execute your code. If it returns false, execute the
code.

Lee Weiner
lee AT leeweiner DOT org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top