JavaFX文本消息未显示

时间:2017-10-04 15:39:04

标签: javafx

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时,不显示消息,为什么?

1 个答案:

答案 0 :(得分:0)

message is displayed in scene1. So if you display scene2, you can't see it. (It can't be in two different scenes.) – James_D Oct 4 at 15:41