代码之家  ›  专栏  ›  技术社区  ›  Morchul drojokef

JavaFX FinishListener空闲方法调用了两次

  •  0
  • Morchul drojokef  · 技术社区  · 5 年前

    我将FinishListener添加到JavaFX应用程序,如果关闭最后一个窗口,idle方法将被调用两次。

    为什么idle方法调用了两次?

    PlatformImpl.addListener(new PlatformImpl.FinishListener() {
        @Override
        public void idle(boolean implicitExit) {
            System.out.println("Idle " + implicitExit);
        }
    
        @Override
        public void exitCalled() {
            System.out.println("Exit called");
        }
    });
    
    //Output after closing the window by pressing x on the top right:
    Idle true
    Idle true
    
    0 回复  |  直到 5 年前