Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to select multiple values using JCheckbox

 
Narendra kodli
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

Can any buddy tell me, how to select multiple values using JCeckbox??? so that when i press submit button it should display all selected values.



 
Nitin Surana
Ranch Hand
Posts: 129
Java Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not understand what you want. Can you please elaborate?

As far as I got you can have as many jcheckboxes as you want and get all of them submitted on clicking submit.
 
Narendra kodli
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

here i am attaching my code please go through it, here when i select multiple values and press submit button and i am getting only single value, so please help me to solve.


 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Narendra kodli wrote:
here i am attaching my code please

Your code? You're Anil Kumar? Strange of you to be asking questions 12½ years after you wrote it.
http://www.codeguru.com/java/articles/567.shtml
 
Narendra kodli
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darryl Burke
Strange of you to be asking questions 12½ years after you wrote it.


Off course it has been originally written by AnilKumar. But so what? i want my doubt got cleared? doesn't matter who have written the code.
If you know the solution then please tell me.
 
Rob Camick
Ranch Hand
Posts: 2612
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are getting a single selection then you have only have one line selected in the JList.

If you want to get the number of check boxes that you have selected then you need to loop through the ListModel to check the value of each entry.

Checkbox selection has nothing to do with the selection model used by the JList.
 
Rob Spoor
Sheriff
Pie
Posts: 20608
63
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Narendra kodli wrote:Off course it has been originally written by AnilKumar. But so what? i want my doubt got cleared? doesn't matter who have written the code.

It does if you claim it's yours while you haven't written it. In this case it's probably a misunderstanding caused by the "my" part, but if you'd do it in a more serious manner you could get sued. You definitely would not want that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic