-1
stage = primaryStage;
Text message = new Text();
pane1 = new GridPane();
pane1.add(message, 0, 0);
scene1 = new Scene(pane1);
//scene2 is built and similar to scene.
if (getAns() == false) {
message.setText("Wrong");
stage.setScene(scene1);
} else {
message.setText("Correct");
stage.setScene(scene2);
}
stage.setTitle("Test");
stage.show();
當getAns()爲true時,顯示消息。當getAns()爲false時,不顯示消息,爲什麼?JavaFX不顯示短信
'scene1'中顯示'message'。所以如果你顯示'scene2',你看不到它。 (它不能在兩個不同的場景。) –
好吧,我明白了。謝謝James_D –