1,105,594 Community Members

How to make CheckBoxList !?

Member Avatar
xzero1
Newbie Poster
9 posts since Jan 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
DavidKroukamp
Master Poster
737 posts since Dec 2011
Reputation Points: 105 [?]
Q&As Helped to Solve: 180 [?]
Skill Endorsements: 4 [?]
Team Colleague
Featured
 
1
 

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

Member Avatar
JamesCherrill
... trying to help
10,406 posts since Apr 2008
Reputation Points: 2,094 [?]
Q&As Helped to Solve: 1,752 [?]
Skill Endorsements: 47 [?]
Moderator
Featured
 
0
 

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?

Member Avatar
xzero1
Newbie Poster
9 posts since Jan 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
DavidKroukamp
Master Poster
737 posts since Dec 2011
Reputation Points: 105 [?]
Q&As Helped to Solve: 180 [?]
Skill Endorsements: 4 [?]
Team Colleague
Featured
 
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

Member Avatar
JamesCherrill
... trying to help
10,406 posts since Apr 2008
Reputation Points: 2,094 [?]
Q&As Helped to Solve: 1,752 [?]
Skill Endorsements: 47 [?]
Moderator
Featured
 
0
 

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

Member Avatar
mKorbel
Nearly a Posting Virtuoso
1,346 posts since Feb 2011
Reputation Points: 274 [?]
Q&As Helped to Solve: 277 [?]
Skill Endorsements: 14 [?]
 
0
 

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

Member Avatar
xzero1
Newbie Poster
9 posts since Jan 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: