为了账号安全,请及时绑定邮箱和手机立即绑定

Stage.close()无法使用JavaFX

Stage.close()无法使用JavaFX

白猪掌柜的 2021-05-05 14:16:41
我有一个主窗口,当我按一个按钮时,另一个窗口将打开。一定时间后,该窗口应关闭。因为它扩展了,所以stage我用super.close,但是不起作用。我能做什么?可能是因为我在服务任务中关闭了它导致的吗?public Game(int width, int height, int time) {    this.width = width - 15;    this.height = height - 15;    this.time = time;    this.layout = generateLayout();    this.scene = new Scene(this.layout, this.width, this.height);    super.initModality(Modality.APPLICATION_MODAL);    super.setScene(scene);    super.setResizable(false);    super.setTitle(TITLE);    this.cicle.reset();    this.cicle.start();    super.showAndWait();}在cicle我的电话里close()有点困惑,但这是cicle服务任务:Service<Void> cicle = new Service<Void>() {    @Override    protected Task<Void> createTask() {        return new Task<Void>() {            volatile boolean waiting = false;            @Override            protected Void call() throws Exception {                Timer.start();                while (Timer.update() / 1000 < time) {                    System.out.println(Timer.update())                }                close();                return null;            }        };    }};
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 109 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信