We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,031 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

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.

4
Contributors
7
Replies
9 Hours
Discussion Span
1 Year Ago
Last Updated
8
Views
xzero1
Newbie Poster
9 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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
Master Poster
Team Colleague
735 posts since Dec 2011
Reputation Points: 279
Solved Threads: 181
Skill Endorsements: 4

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
... trying to help
Moderator
8,516 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,455
Skill Endorsements: 30

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
9 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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
Master Poster
Team Colleague
735 posts since Dec 2011
Reputation Points: 279
Solved Threads: 181
Skill Endorsements: 4

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
... trying to help
Moderator
8,516 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,455
Skill Endorsements: 30

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
Nearly a Posting Virtuoso
1,214 posts since Feb 2011
Reputation Points: 482
Solved Threads: 239
Skill Endorsements: 12

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

xzero1
Newbie Poster
9 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.1074 seconds using 2.69MB