• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

List with checkboxes

 
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic