class BridgeServiceFX : BridgeService { override fun getBrowserName(): String { var ret : Optional? = null if (Platform.isFxApplicationThread()) { println("running on FX thread") val ret = makeDialog().showAndWait() println(ret) } else { println("not on a fx thread") val task = FutureTask>(Callable { makeDialog().showAndWait() }) Platform.runLater(task) ret = task.get() } return ret?.get()?: "" } private fun makeDialog(): TextInputDialog { val dialog = TextInputDialog().apply { dialogPane.lookupButton(ButtonType.OK).disableProperty().bind(booleanBinding(editor.textProperty(), editor.textProperty()) { value.isBlank() }) title = FX.messages["browsernametitle"] contentText = "Browser name" } return dialog } }