Home arrow static arrow Java Programming [Archive] - JList of Check Boxes
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - JList of Check Boxes
This topic has 3 replies on 1 page.

Posts:2
Registered: 7/17/04
JList of Check Boxes  
Jul 17, 2004 1:02 PM



 
I'm trying to create a JList containing a list of check boxes. I've create a vector of check box objects (vCheckBox) and I instantiate the list as follows : list = new JList(vCheckBox). When the JList displays on the screen what I get in the list is the 'toSting' representation of the check box objects. I tried to create a ListCellRenderer that simply recasts the the vector object as a JCheckBox and I get the check boxes in the list but they are all disabled and I can't figure out a way to enable them in the list. I've tried all of the obvious things.
Any thoughts? Thanks!
 

Posts:8,813
Registered: 10/4/00
Re: JList of Check Boxes  
Jul 17, 2004 1:13 PM (reply 1 of 3)



 
Jlist doesn't support an editing component directly. [url http://forum.java.sun.com/thread.jsp?forum=257&thread=119663]Here's[/url] someone who looks like they faked it. Have you thought about using a single column jtable with a cell editor?
 

Posts:2
Registered: 7/17/04
Re: JList of Check Boxes  
Jul 17, 2004 1:32 PM (reply 2 of 3)



 
Yes. Actually, i created a 2 column JTable (first column is a boolean, second column is a description). When the boolean is represented by a check box when displayed in the table. I created code so if the user selects the description cell it will select/deselect the coresponding checkbox. It works well and actually looks like a JCheckbox. I was just seeing if the JList implementation would be simplier and require less code.
 

Posts:24,517
Registered: 98-02-27
Re: JList of Check Boxes  
Jul 17, 2004 2:29 PM (reply 3 of 3)



 
Just create a panel with a GridLayout and add all your JCheckBoxes to the panel. You can add the panel to a JScrollPane is needed.
 
This topic has 3 replies on 1 page.