Scala/JavaFX: A Platform.runLater Runnable example

As a brief note to self, this is some code I wrote to update my GUI in a JavaFX application:

val runnable = new Runnable {
    override def run(): Unit = {
        val htmlPane = new HtmlDialogPane
        htmlPane.htmlTextArea.setText(html)
        GuiUtils.showHtmlDialog("Your HTML", htmlPane)
    }
}
Platform.runLater(runnable)

The keys here are in creating the Runnable, and knowing to use Platform.runLater to update the GUI. Per the Platform docs, “Run the specified Runnable on the JavaFX Application Thread at some unspecified time in the future. This method, which may be called from any thread, will post the Runnable to an event queue and then return immediately to the caller.”