更新标签和切换场景JavaFX

更新标签和切换场景JavaFX,java,javafx,label,Java,Javafx,Label,我只从YouTube上的基本教程中学习了JavaFX,还学会了切换这样的场景。但是在我的应用程序中并没有关于更新标签的内容 我有以下代码: import javafx.application.*; import javafx.stage.*; import javafx.scene.*; import javafx.scene.layout.*; import javafx.scene.control.*; public class GUI extends Application {

我只从YouTube上的基本教程中学习了JavaFX,还学会了切换这样的场景。但是在我的应用程序中并没有关于更新标签的内容

我有以下代码:

import javafx.application.*;
import javafx.stage.*;
import javafx.scene.*;
import javafx.scene.layout.*;
import javafx.scene.control.*;

public class GUI extends Application {
    Stage window;
    Scene setup, results;
    Button next;
    Label statusL2; 

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        window = primaryStage;
        next = new Button("Go to the next scene");
        next.setOnAction(e -> {
                window.setScene(results);
                statusL2 = new Label("GOOD STRING");
        });
        StackPane setupLayout = new StackPane();
        setupLayout.getChildren().addAll(next);
        setup = new Scene(setupLayout, 554, 263);
        statusL2 = new Label("STRING WHICH SHOULDN'T BE SHOWN AT ANY POINT");
        VBox resultsLayout = new VBox();
        resultsLayout.getChildren().addAll(statusL2);
        results = new Scene(resultsLayout, 700, 500);
        window.setScene(setup);
        window.show();

    }
}
我想在第二个场景中展示“好弦”。我应该将文本更新(setText())放在另一个线程中吗


如果是,如果不是静态的,我如何调用statusL2的方法?它属于哪个物体

只需将操作处理程序中的一行更改为

            statusL2.setText("GOOD STRING");