How to de-select a JList item from my program
Asked Answered
J

1

5

I have a JList, and a JButton, user can click an item in the JList or they can click the button, when the button is clicked how do I de-select (change the selected list item bgcolor to normal, in other words, nothing in the JList will be selected after the button is clicked) the item from the JList ?

Jammiejammin answered 1/9, 2009 at 3:43 Comment(0)
F
12

The JList should have a clearSelection() method that you can call.

Fluecure answered 1/9, 2009 at 3:54 Comment(1)
I was having a problem finding a way to do this - but this easily cleared it up. Thanks much, though its a shame there is not a simpler way to clear the selection (such as say, setting the selected index to -1 or something).Saguaro

© 2022 - 2024 — McMap. All rights reserved.