javafx - JAVA FX - Hide stage lost service task response -
in this post answer why ui blocking after service.start() call, , resolved. have "little" problem... after start() service hide/close stage run application on trayicon.
i've noticed hide()/close() stage, service blocked , never go in succeeded status. i've tried remove call , works.
how can hide()/close() stage without block service thread , receive answer minimize on tray?
@fxml private void handleregisterbutton() { user newuser = new user(); newuser.setusername(usernametextfield.gettext()); newuser.setgroup(groupchoichebox.getselectionmodel().getselecteditem()); newuser.setmachinename(machinenametextfield.gettext()); this.mainapp.registernewuser(newuser); // primarystage main registeruserinvocation service = new registeruserinvocation(newuser); service.stateproperty().addlistener(new invalidationlistener() { @override public void invalidated(observable observable) { system.out.println("task value " + service.getstate()); if(service.getstate().equals(worker.state.succeeded)) { mainapp.showmessageontray("lan alert", "attivo!", messagetype.info); // handler method show traymessage } } }); service.start(); /* if remove application works. sure, window remain visible*/ this.mainapp.getprimarystage().close(); }
you need invoke platform.setimplicitexit(false), otherwise javafx runtime shut down when close last stage.
see sample using trayicon , javafx.
Comments
Post a Comment