Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > JList problem

Reply
Thread Tools

JList problem

 
 
Mika Suomi
Guest
Posts: n/a
 
      09-23-2004
class AsiakasListaHndl implements ListSelectionListener{
public void valueChanged(ListSelectionEvent e) {
JList jlst= new JList(lstCustomers);
String name=(String) jlst.getSelectedValue();
System.out.println(name);}}

This is code in listener and when I click a customer in list it gives the
result twice.First when I click mouse second when I release mouse.Why???

Mika Suomi


 
Reply With Quote
 
 
 
 
Paul Lutus
Guest
Posts: n/a
 
      09-23-2004
Mika Suomi wrote:

> class AsiakasListaHndl implements ListSelectionListener{
> public void valueChanged(ListSelectionEvent e) {
> JList jlst= new JList(lstCustomers);
> String name=(String) jlst.getSelectedValue();
> System.out.println(name);}}
>
> This is code in listener and when I click a customer in list it gives the
> result twice.First when I click mouse second when I release mouse.Why???


The problem is located in the code you didn't post.

--
Paul Lutus
http://www.arachnoid.com

 
Reply With Quote
 
 
 
 
Babu Kalakrishnan
Guest
Posts: n/a
 
      09-24-2004
Mika Suomi wrote:
> class AsiakasListaHndl implements ListSelectionListener{
> public void valueChanged(ListSelectionEvent e) {
> JList jlst= new JList(lstCustomers);
> String name=(String) jlst.getSelectedValue();
> System.out.println(name);}}
>
> This is code in listener and when I click a customer in list it gives the
> result twice.First when I click mouse second when I release mouse.Why???
>


Try calling getValueIsAdjusting() on the event object and avoid doing
your action if it returns true. (In that case it is an event generated
as a part of a sequence of events)

BK
 
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
problem with JList tolu45 Java 2 11-24-2005 06:33 PM
Jlist problem Mika Suomi Java 6 02-21-2004 08:53 AM
Problem with JList, DefaultListModel and JScrollPane Tobi Krausl Java 0 11-12-2003 11:20 AM
JList problem. Tom Java 1 07-30-2003 12:53 PM
JList question Passero Java 1 06-28-2003 12:17 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57