scut小辣鸡 2017-10-15 15:04 采纳率: 50%
浏览 2721

新人问题 JavaFx的Stage跳转问题

package cn.learn.filewriter;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.GridPane;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class Filewriter extends Application {
private Stage stage = new Stage();
private Stage stage1 = new Stage();
private Stage stage2 = new Stage();
private final int SCREENWIDTH = 333;
private final int SCREENHEIGHT = 300;

public void start(Stage primaryStage) {
    GridPane borderPane = new GridPane();
    Button btBack = new Button("OK");
    Text text=new Text("Stage");

    borderPane.add(btBack, 0, 0);
    borderPane.add(text, 0, 1);
    Scene scene = new Scene(borderPane, SCREENWIDTH, SCREENHEIGHT);
    stage.setScene(scene);
    stage.setTitle("Bank");
    stage.show();

    btBack.setOnAction(e -> fun1());
}

public void fun1() {
    GridPane borderPane = new GridPane();
    Button btBack = new Button("Back");
    Button btOk=new Button("OK");
    Text text=new Text("Stage1");


    borderPane.add(btBack, 5, 5);
    borderPane.add(btOk, 1, 5);
    borderPane.add(text, 0, 1);
    Scene scene = new Scene(borderPane, SCREENWIDTH, SCREENHEIGHT);
    stage1.setScene(scene);
    stage1.setTitle("Bank");
    stage1.show();

    btOk.setOnAction(e->fun2());

}

public void fun2() {
    GridPane borderPane = new GridPane();
    Button btBack = new Button("Back");
    Text text=new Text("Stage2");

    borderPane.add(btBack, 0, 0);
    borderPane.add(text, 0, 1);
    Scene scene = new Scene(borderPane, SCREENWIDTH, SCREENHEIGHT);
    stage2.setScene(scene);
    stage2.setTitle("Bank");
    stage2.show();

    btBack.setOnAction(e -> start(stage1));
}

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

}
比如这段代码
我想Stage2的back回到Stage1
应该怎么实现?
谢谢大家!

  • 写回答

3条回答 默认 最新

  • scut小辣鸡 2017-10-16 14:04
    关注

    有人吗图片说明这个问题搞不是很懂

    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料