I tortured google with multiple questions but still cant get a point.
I want to build app with 2 FXML scenes populated by SceneBuilder. Each have it's own controller. I use ControlledScreen to swap Scenes and this works. But then i cant change anything on scene. For example: i have label in Scene Controller:
public class ControllerForm implements ControlledScreen, Initializable {
ScreensController myController;
GraphicsContext GC;
@FXML
private Label fitnessLabel;
public void updateFitnessLabel(double data) {
fitnessLabel.setText(String.valueOf(data));
}
public void initialize(URL location, ResourceBundle resources) {
this.GC = neuroCanvas.getGraphicsContext2D();
}
It's defined in FXML file as:
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="684.0" prefWidth="918.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="general.ControllerForm">
<left>
<VBox prefHeight="400.0" prefWidth="189.0" BorderPane.alignment="CENTER">
<children>
<Label fx:id="fitnessLabel" text="Label">
<graphic>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Fitness:" />
</graphic>
</Label>
And function to update label is updateFitnessLabel.
In initialize method i use GC cuz i have canvas on this scene and want to draw on it.
I have method that is calling for this fucntion as:
public class Net {
private ControllerForm controller;
public void drawStart() throws IOException {
FXMLLoader loader = new FXMLLoader(
getClass().getResource(
Main.ScreenFile
)
);
BorderPane cv = loader.load();
// load actual screen
ControllerForm controller =
loader.<ControllerForm>getController();
controller.updateFitnessLabel(12);}
But no effect. Label wont be updated.
What am i missing ?
I tried to use Timeline, but still no effect. How to actuall draw something on this scene ?