private void bindServiceToControl(ServiceAndTask demoControl, Service<String> service) { demoControl.startService.setOnMouseClicked( (val) -> { if (!service.isRunning()) { service.reset(); service.start(); demoControl.labelService.textProperty().bind(service.messageProperty()); } }); demoControl.labelService.textProperty().bind(service.messageProperty()); service.addEventHandler( WorkerStateEvent.WORKER_STATE_SUCCEEDED, (val) -> { demoControl.labelService.textProperty().unbind(); demoControl.labelService.setText(service.getValue()); }); demoControl.progressService.progressProperty().bind(service.progressProperty()); }