Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Deselection of Items in a JList  RSS feed

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Matt Senecal
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 255
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You the man Matt. Thanks a mil!!

------------------
Happy Coding,
Gregg Bolinger
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!