I have the following code where I have to control if a food has x ingredients, the thing is that if you meet the ingredients but you select one more, you also consider it good because the code is as follows
if(radioLentejas.isSelected()){
if(chkChorizo.isSelected() && chkMorcilla.isSelected() && chkGarbanzos.isSelected() && chkZanahoria.isSelected()){
lblResultado.setText("Correcto");
}else{
lblResultado.setText("Equivocado!");
}
}
my doubt would be if there is any way to control that only take those elements and none more, because for example if you select those elements but some more would also give it for good
In response, thank you very much to @Jakala, JFrame brings the next event for when the status changes, adding a counter will be enough to then check if the number of checks is correct:
private void chkPimentonItemStateChanged(java.awt.event.ItemEvent evt) {
if(chkPimenton.isSelected()){
countChecked++;
}else if(!chkPimenton.isSelected()){
countChecked--;
}
lblResultado.setText(String.valueOf(countChecked));
}