This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

List with checkboxes  RSS feed

 
Manish Hatwalne
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a particular requirement. -
I need a JList which has list of elements along with checkboxes. But
checkbox should be clicked only if the user clicks on the checkbox itself,
and not otherwise. (So simple renderer won't do). Moreover, clicking on row should only select the row, and not the checkbox shouldn't be clicked unless click is on checkbox itself. While getting data from the list, (selected objects), it should also return if checkbox was clicked fr the particular row or not.
How can I do this? The reason it is a JList because it's legacy code and
there are listeners which do lot of things based on selected items. The
checkbox is new requirement.
What would be the other preferred way of doing this?
TIA,
- Manish
 
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 did this before. I just drudged up my code from a year ago. So I'm not too sure how well I remember it to explain what I did. But you should be able to figure it out.
CheckableItem

ChecklistRenderer

Creating the Array of those Items

The implementation

Hopefully that will get you the gist of what you need.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!