954,545 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to make CheckBoxList !?

Hi all,
I am a beginner in Java, making GUI in blueJ. I want to use CheckBoxList for multiple selection from a list for users.. I just want to learn how to make one of that. I saw some codes here .They use some sort of CheckListRenderer. I am also unfamiliar with that ! so someone please Guide me to to so.
Thnaks.

xzero1
Newbie Poster
5 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
 
Hi all, I am a beginner in Java, making GUI in blueJ. I want to use CheckBoxList for multiple selection from a list for users.. I just want to learn how to make one of that. I saw some codes here .They use some sort of CheckListRenderer. I am also unfamiliar with that ! so someone please Guide me to to so. Thnaks.


here is some links that could help: http://docs.oracle.com/javase/6/docs/api/javax/swing/ListCellRenderer.html and http://www.devx.com/tips/Tip/5342 and also maybe this: http://stackoverflow.com/questions/19766/how-do-i-make-a-list-with-checkboxes-in-java-swing

DavidKroukamp
Practically a Master Poster
Team Colleague
693 posts since Dec 2011
Reputation Points: 282
Solved Threads: 169
 

I don't want to discourage you, but if you are a beginner you will probably find custom renderers and custom editors pretty challenging. Do you really have to use check boxes? Perhaps you can just use an ordinary multiple-selection JList for now?

JamesCherrill
Posting Genius
Moderator
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
 

ya i used jlist for single selection. also tried it for multiple selection but got some error while i was using the method "getSelectedValues()" of jlist in the "OK" JButton. so i thought to use CheckBoxList. i guessed that will be easy :p.. if you help me, how to get multiple selected values in from JList to use them in my program. i will do so.

xzero1
Newbie Poster
5 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
 
ya i used jlist for single selection. also tried it for multiple selection but got some error while i was using the method "getSelectedValues()" of jlist in the "OK" JButton. so i thought to use CheckBoxList. i guessed that will be easy :p.. if you help me, how to get multiple selected values in from JList to use them in my program. i will do so.


see here for use of JLists: http://docs.oracle.com/javase/tutorial/uiswing/components/list.html

DavidKroukamp
Practically a Master Poster
Team Colleague
693 posts since Dec 2011
Reputation Points: 282
Solved Threads: 169
 

Easiest way with multiple selections is JList's getSelectedIndices method

public int[] getSelectedIndices()

Returns an array of all of the selected indices, in increasing order, or an empty array if nothing is selected

JamesCherrill
Posting Genius
Moderator
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
 

it too hard to implementing JList & Render with some of dirty hack, use JTable with one Column,

1) JTable with JCheckBox is represented with Boolean value only

2) no required any code for Renderer/Editor, because JTable knows Boolean value

3) JTable must be editable for Editor

4) everything here

mKorbel
Veteran Poster
1,141 posts since Feb 2011
Reputation Points: 480
Solved Threads: 224
 

ya. thanks. i just want to use the checkboxlist.......... curious you know :)

xzero1
Newbie Poster
5 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: