• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question about jcheckbox

 
Kevin Pang
Ranch Hand
Posts: 38
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to achieve the "check all" function and get the value from all jcheckbox checked ? how to do the function in swing as in javascript getElementById() ?
thanks.
 
Kevin Pang
Ranch Hand
Posts: 38
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
solved
Container c = jck.getParent();
Component[] comps = c.getComponents();
for (Component comp : comps) {
if (comp instanceof JCheckBox) {
if (((JCheckBox) comp).isSelected()) {
rsltInfor.append(((JCheckBox) comp).getText() + " ");
}
}

}
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic