JList problem

M

Mika Suomi

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
 
P

Paul Lutus

Mika said:
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.
 
B

Babu Kalakrishnan

Mika said:
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
 

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,774
Messages
2,569,598
Members
45,150
Latest member
MakersCBDReviews
Top