所以你希望每个类都是舞台的子类。我会给你两个阶段以及如何互相交流。
public class FirstStage extends Stage{
Button openOther = new Button("Open other Stage");
HBox x = new HBox();
FirstStage(){
x.getChildren().add(openOther);
this.setScene(new Scene(x, 300, 300));
this.show();
openOther.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent t) {
new SecondStage();
}//end action
});
}
}
为第二阶段,
public class SecondStage extends Stage {
Label x = new Label("Second stage");
VBox y = new VBox();
SecondStage(){
y.getChildren().add(x);
this.setScene(new Scene(y, 300, 300));
this.show();
}
}
而且从主第一阶段叫:
@Override
public void start(Stage primaryStage){
new FirstClass();
}
你可以添加一些上下文这个答案? –