I've tried to make a little math program with JavaFX. I have a Button
action in Controller 1:
@FXML
public void showCalc(ActionEvent event2) {
layout.parabel_nullstelle_showCalc.setVariables(a, b, c, x1, x2, ze1, ze2, ze3, ze4, ze5, ze6, ze7);
Parent root3 = main.Main.getParent();
Scene showCalc = new Scene(root3, 500, 1000);
Stage paranullCalc = new Stage();
paranullCalc.setTitle("Rechung");
paranullCalc.setScene(showCalc);
paranullCalc.show();
}
It opens a new Stage
with Scene
which contains a calculation.
In the Controller for the showCalc
I have the set variables method.
public static void setVariables(double a1, double b1, double c1,double x11, double x22, double ze11, double ze22, double ze33, double ze44, double ze55, double ze66, double ze77){
a = (float) a1;
b = (float) b1;
c = (float) c1;
x1 = (float) x11;
x2 = (float) x22;
ze1 = (float) ze11;
ze2 = (float) ze22;
ze3 = (float) ze33;
ze4 = (float) ze44;
ze5 = (float) ze55;
ze6 = (float) ze66;
ze7 = (float) ze77;
}
I needed to make it static because I can't do an object of a controller and with import I get the static/non static error. But now I want to change the text of a TextArea
in the same Scene
as the setVariables
, so I can show the calculation. I can't make the TextArea
static, because then it crashes. I also can't access it without static and creating an object of itself also isn't a solution. So how do I solve this?