JavaFX 8 Tutorial 41 - Validate and Clear CheckBox
The code written in the tutorial is:
checkBox1.requestFocus();
checkBox2.requestFocus();
checkBox3.requestFocus();
private boolean validateFields(){
if(!(checkBox1.isSelected() | checkBox2.isSelected() | checkBox3.isSelected())){
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Validate Fields");
alert.setHeaderText(null);
alert.setContentText("Please Selct One of The Hobby ");
alert.showAndWait();
return false;
}
return true;
}
public void clearFields(){
checkBox1.setSelected(false);
checkBox2.setSelected(false);
checkBox3.setSelected(false);
checkBoxList.clear();
}
Comments
Post a Comment