wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Display selected item in JList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Display selected item in JList" Watch "Display selected item in JList" New topic
Author

Display selected item in JList

Pres Brawner
Ranch Hand

Joined: Jan 18, 2001
Posts: 92
I've got a JList that is part of JScrollPane.
I do a search in a database for a value. I then match that value with the value in the JList. I then setSelected on the item in the JList. All this is OK.
However, my JList still displays the first item in the list, not my item. I know the index of the item I want to display. This should be dead-bang easy, but for some reason, I can't think of the solution.
Thanks,
Pres
Thomas Suer
Ranch Hand

Joined: Sep 03, 2001
Posts: 50
What about using the JList's method
?
Tom
[This message has been edited by Thomas Suer (edited November 09, 2001).]
Pres Brawner
Ranch Hand

Joined: Jan 18, 2001
Posts: 92
That was it!
Vinod Venugopal
Ranch Hand

Joined: Dec 06, 2000
Posts: 148
Hey I faced a similar problem with this setSelectedValue() method when I wanted to select multiple values in a JList automatically, it still selected only once, is there a way ?
Regards,
Vinod


- Vinod<br />-------<br />SCJP2
 
wood burning stoves
 
subject: Display selected item in JList
 
Similar Threads
Retaining value of checkbox when returning back from a servlet
problem selecting JList item
A Few Questions
How to show JCheckBox component as elements of a JList ?
JList - items in different color