JavaFX app in System Tray

前端 未结 5 751
有刺的猬
有刺的猬 2020-11-30 07:49

I am Making a Simple App using JavaFX UI, The app simply just do that:

  • has a systray icon, which when clicked shows a window, when clicked again hides it, on
5条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-30 08:27

    You should only modify the javafx classes on the javafx thread, the listeners on the tray icon are likely to be running on the swing thread. You can do this by posting a runnable to Platform#runLater like so:

    Platform.runLater(new Runnable() {
        public void run() {
            primaryStage.hide();
        }
    });
    

提交回复
热议问题