Hi guys, I want to show a dialog with JList component in it. Now i want to display a JCheckBox component instead of a simple text label in the JList. So that it would enable my user to select/unselect the checkbox when the users click on an item in the JList. I have found that there is no method to provide an editor for the the JList component. It is possible to provide an editor in the JTable and JTree. Any suggetions are welcome.
I would recomend not using a JList for what you want to do. It just doesn't make sense really. I asume that the reason you need JCheckBox's in a JList is so that you can have a large list and scroll through the list of JCheckbox elements. If you have another reason, I would like to know what it is. However, if my assumption is correct you can put a JPanel in a JScrollPane. Place all your JCheckBoxes on the JPanel. Then you can scroll up and down the JPanel if you have that many JCheckBox elements.
Vishal, Here's a suggestion: Use a "JTable" with one column. Hide the "grid" lines (using method "setShowHorizontalLines()" in class "JTable"). Make the class of the column "Boolean" (see method "getColumnClass()" in interface "TableModel"). The default renderer for such a column is a "JCheckBox". Finally, place the "JTable" in a "JScrollPane". This should give you the desired effect. Hope this has helped you. Good Luck, Avi.