I am working on a Simple JavaFX Calculator for school, I am stuck on putting together an Action Event that take the input from both text fields, the radio button that is selected, and the perform that event when the calculate button is pressed.
btnCalc.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent e) {
}
});
}
public void calculation(ActionEvent e) {
int num1, num2, answer;
num1 = Integer.parseInt(tfNum1.getText());
num2 = Integer.parseInt((tfNum2.getText()));
if (rbAdd.isSelected()) {
answer = num1 + num2;
} else if (rbSubtract.isSelected()) {
answer = num1 - num2;
} else if (rbMultiply.isSelected()) {
answer = num1 * num2;
} else {
answer = num1 / num2;
}
tfAns.setText(String.valueOf(answer));