Controller.java
public TextField l4M1ICT01;
public TextField l4M1ICT02;
public TextField l4M1CourseWork;
public TextField l4M1Average;
public int average_1;
public int credit_1;
public void l4M1AverageButtonClicked(ActionEvent event) throws IOException {
int l4M1ICT01_1 = Integer.parseInt(l4M1ICT01.getText());
int l4M1ICT02_1 = Integer.parseInt(l4M1ICT02.getText());
int l4M1CourseWork_1 = Integer.parseInt(l4M1CourseWork.getText());
average_1 = (l4M1ICT01_1 + l4M1ICT02_1 + l4M1CourseWork_1) / 3;
l4M1Average.setText(average_1 + "");
if(average_1 >= 40){
credit_1 = 20;
}else{
credit_1 = 0;
}
System.out.println(credit_1);
}
public void l4M1NextButtonClicked(ActionEvent event) throws IOException {
((Node) (event.getSource())).getScene().getWindow().hide();
//loading the next scene
Parent parent = FXMLLoader.load(getClass().getResource("L4M2.fxml"));
Stage stage = new Stage();
Scene scene = new Scene(parent);
stage.setScene(scene);
stage.setTitle("Level 4 Module 2");
//making the scene appear on the screen
stage.show();
}
public TextField l4M2ICT01;
public TextField l4M2ICT02;
public TextField l4M2CourseWork;
public TextField l4M2Average;
public int average_2;
public void l4M2AverageButtonClicked(ActionEvent event) throws IOException {
int l4M2ICT01_1 = Integer.parseInt(l4M2ICT01.getText());
int l4M2ICT02_1 = Integer.parseInt(l4M2ICT02.getText());
int l4M2CourseWork_1 = Integer.parseInt(l4M2CourseWork.getText());
average_2 = (l4M2ICT01_1 + l4M2ICT02_1 + l4M2CourseWork_1) / 3;
l4M2Average.setText(average_2 + "");
System.out.println(credit_1);
}
public void l4M2NextButtonClicked(ActionEvent event) throws IOException {
((Node) (event.getSource())).getScene().getWindow().hide();
//loading the next scene
Parent parent = FXMLLoader.load(getClass().getResource("L4M3.fxml"));
Stage stage = new Stage();
Scene scene = new Scene(parent);
stage.setScene(scene);
stage.setTitle("Level 4 Module 3");
//making the scene appear on the screen
stage.show();
}
this is a portion of my javafx code i've been working on. on the first scene if i give 40+ as input for l4M1ICT01 it should save 20 as credit anything less than 40 should save or initialize the credit value to 0. when i print it inside the same 1st button click command it prints 20 for credit when i give a 40+ input then as soon as that method is over i tried to print the same value i got in the above method on my 2nd scene but now it only shows 0. how to pass that value through the scenes so i can use it as the end? thanks. I've used scene builder to code javafx.