JList problem.

Discussion in 'Java' started by Tom, Jul 30, 2003.

  1. Tom

    Tom Guest

    Hi,

    I have a JList with some String values in it and i have a ScrollPane tied
    to the JList. Now the problem. When you have made a selection from the JList
    i want to set my JList to the start value again but i cant get it to work.
    I've tried with the JList methods: setSelectedIndex(int index), clearSelection(),
    but nothing happends. So no i wonder how to set my JList to show the index
    value i want?

    Best Regards
    Tom
     
    Tom, Jul 30, 2003
    #1
    1. Advertising

  2. Tom

    Ike Guest

    I think you need to work with a ListModel. Create a list model to add the
    data to, then create the JList to display the list:

    listmodel_1=new DefaultListModel();
    jList1=new JList(listmodel_1);

    you may be able to just get the list model from your already data-populated
    JList, and set teh selected index on that. -Ike

    "Tom" <> wrote in message
    news:3f26fe72$0$7161$...
    >
    > Hi,
    >
    > I have a JList with some String values in it and i have a ScrollPane tied
    > to the JList. Now the problem. When you have made a selection from the

    JList
    > i want to set my JList to the start value again but i cant get it to work.
    > I've tried with the JList methods: setSelectedIndex(int index),

    clearSelection(),
    > but nothing happends. So no i wonder how to set my JList to show the index
    > value i want?
    >
    > Best Regards
    > Tom
     
    Ike, Jul 30, 2003
    #2
    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,113
    Stephan Friedrichs
    Jun 28, 2003
  2. Tobi Krausl
    Replies:
    0
    Views:
    1,815
    Tobi Krausl
    Nov 12, 2003
  3. Mika Suomi

    Jlist problem

    Mika Suomi, Feb 20, 2004, in forum: Java
    Replies:
    6
    Views:
    3,055
    Mika Suomi
    Feb 21, 2004
  4. Mika Suomi

    JList problem

    Mika Suomi, Sep 23, 2004, in forum: Java
    Replies:
    2
    Views:
    458
    Babu Kalakrishnan
    Sep 24, 2004
  5. tolu45

    problem with JList

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

Share This Page