I am trying to create a rating prototype in java, were a use can rate the aspect by clicking the checkbox. I am trying to capture the values for selected checkbox inside the table and calculate they average. And I want the user to be able to select only one checkbox in each row.
See the image to get a clear idea of what I mean
enter code here
int rating;
int checkBox;
int average = 0;
for(int a=0; a<jTable1.getRowCount(); a++){
Boolean isChecked = Boolean.valueOf(jTable1.getValueAt(a, +1).toString());
if (isChecked) {
rating =+1;
//get the values of the columns you need.
} else {
System.out.printf("Row %s is not checked \n", a);
}
for(int c=1; c<jTable1.getColumnCount(); c++){
//if( jTable1.getValueAt(c, 1).isSelected()==true){
//rating = 1;
//}
}
}
See the image here to have a clear idea of what i am saying
Aucun commentaire:
Enregistrer un commentaire