JList problem.

T

Tom

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
 
I

Ike

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
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top