JList problem

Discussion in 'Java' started by Mika Suomi, Sep 23, 2004.

  1. Mika Suomi

    Mika Suomi Guest

    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
    Mika Suomi, Sep 23, 2004
    #1
    1. Advertising

  2. Mika Suomi

    Paul Lutus Guest

    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
    Paul Lutus, Sep 23, 2004
    #2
    1. Advertising

  3. 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
    Babu Kalakrishnan, Sep 24, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Passero

    JList question

    Passero, Jun 28, 2003, in forum: Java
    Replies:
    1
    Views:
    1,105
    Stephan Friedrichs
    Jun 28, 2003
  2. Tom

    JList problem.

    Tom, Jul 30, 2003, in forum: Java
    Replies:
    1
    Views:
    708
  3. Tobi Krausl
    Replies:
    0
    Views:
    1,812
    Tobi Krausl
    Nov 12, 2003
  4. Mika Suomi

    Jlist problem

    Mika Suomi, Feb 20, 2004, in forum: Java
    Replies:
    6
    Views:
    3,042
    Mika Suomi
    Feb 21, 2004
  5. tolu45

    problem with JList

    tolu45, Nov 24, 2005, in forum: Java
    Replies:
    2
    Views:
    749
Loading...

Share This Page