edvin / tornadofx-guide

TornadoFX Guide
133 stars 67 forks source link

Load an fxml from a string #107

Closed TKPGitHub closed 5 years ago

TKPGitHub commented 5 years ago

Hi Edvin, Is there a way to load an fxml from a STRING ? The documentation only mentions: override val root : BorderPane by fxml() or by fxml("path_to_fxml_file")

How about writting something like this: override val root : BorderPane by fxml(ByteArrayInputStream(FXML_STRING.getBytes()))

The reason of my request i have my fxml files are stored in the database.

Found a javafx solution from https://stackoverflow.com/questions/16548925/how-to-load-fxml-from-string-in-javafx : FXMLLoader loader = new FXMLLoader(); AnchorPane layout = (AnchorPane) loader.load( new ByteArrayInputStream(FXML_STRING.getBytes()) );

Thks

edvin commented 5 years ago

Hi,

I've just committed support for loading FXML from an InputStream. Does that cover your use case? :)

TKPGitHub commented 5 years ago

Hi Edvin, Impressively quick! Yes, I've seen in your implementation in Component.kt (line 1127 ..1140) if I'm not wrong. Thanks Cheers