IntelliJ Java IDE
The moose likes Swing / AWT / SWT / JFace and the fly likes Deselection of Items in a JList Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT / JFace
Reply Bookmark "Deselection of Items in a JList" Watch "Deselection of Items in a JList" New topic
Author

Deselection of Items in a JList

Gregg Bolinger
Sheriff

Joined: Jul 11, 2001
Posts: 15040

I have a JList of Users and a Refresh Button. When the refresh button is hit, I need the getSelectedItem to become null again instead of a value.
Can someone tell me how?
Thanks

------------------
Happy Coding,
Gregg Bolinger


My Blog | DZone Articles
Matt Senecal
Ranch Hand

Joined: Dec 01, 2000
Posts: 255
When the refresh button is pressed, why not do a JList.setSelectedValue(null, false)?
Originally posted by Gregg Bolinger:
I have a JList of Users and a Refresh Button. When the refresh button is hit, I need the getSelectedItem to become null again instead of a value.
Can someone tell me how?
Thanks


There's nothing more dangerous than a resourceful idiot. ---Dilbert
Gregg Bolinger
Sheriff

Joined: Jul 11, 2001
Posts: 15040

Cool, I think it works., But let me ask you this. How do you get the selection to go away. Say I select the 1st name, then I click a refresh button, the item in the list still appears to be selected. I want it to become unselected.
Thanks

------------------
Happy Coding,
Gregg Bolinger
Matt Senecal
Ranch Hand

Joined: Dec 01, 2000
Posts: 255
I think JList.clearSelection() does that.
Originally posted by Gregg Bolinger:
Cool, I think it works., But let me ask you this. How do you get the selection to go away. Say I select the 1st name, then I click a refresh button, the item in the list still appears to be selected. I want it to become unselected.
Thanks


Gregg Bolinger
Sheriff

Joined: Jul 11, 2001
Posts: 15040

You the man Matt. Thanks a mil!!

------------------
Happy Coding,
Gregg Bolinger
 
 
subject: Deselection of Items in a JList
 
Threads others viewed
JList set element visible
Refresh JTable
How can I make JList update when ListModel changed?
Retaining selected value in combo box after refresh
How to identify when refresh button of browser or f5 is pressed
developer file tools