What should be passed to FileChooser?
According to the docs you can pass a null
for the window.
If the owner window for the file dialog is set, input to all windows in the dialog's owner chain is blocked while the file dialog is being shown.
However, since you are using TornadoFX, you may instead just want to use the chooseFile
and chooseDirectory
functions it provides. They automatically handle the hairy parts for you with useful defaults, but (since they are only defaults after all) you can easily override them to tailor the functionality to your needs.
The following code worked for me:
with(root) {
button("Target Directory") {
action {
var dir = chooseDirectory("Select Target Directory")
}
}
}
On Windows, the file chooser dialogue will open "My Computer" by default.