Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > mysterious Jlist behaviour (valuechanged)

Reply
Thread Tools

mysterious Jlist behaviour (valuechanged)

 
 
wnstnsmith@yahoo.com
Guest
Posts: n/a
 
      11-29-2003
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
 
Reply With Quote
 
 
 
 
Lee Weiner
Guest
Posts: n/a
 
      11-29-2003
In article <3fc7fffa$0$4393$(E-Mail Removed)4all.nl> , http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
>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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
debugger behaviour different to execution behaviour Andy Chambers Java 1 05-14-2007 09:51 AM
JList Problems Tom Java 1 07-30-2003 03:15 PM
JList problem. Tom Java 1 07-30-2003 12:53 PM
JList question - how to fire a change event when nothing has changed? Sam Java 0 07-17-2003 10:40 PM
JList question Passero Java 1 06-28-2003 12:17 PM



Advertisments