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 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据