I've ran into a glitch/bug where launching a direc...
# tornadofx
s
I've ran into a glitch/bug where launching a directory chooser will render it at the top left of its stage at default size for what seems like a single frame before visible snapping it to where it should be: Minimal Example:
Copy code
class Example : View() {
    override val root = pane {
        prefWidth = 600.0
        prefHeight = 500.0
        button("click") {
            action {
                val directoryChooser = DirectoryChooser()
                directoryChooser.showDialog(primaryStage)
            }
        }
    }
}
Reproduce: Click the button, move the dialog elsewhere and/or resize it. Close it and click the button again. The dialog will briefly render at the top left before snapping to the last position/size the user set it. This is using Javafx 15, Kotlin 1.4.10 and the latest 2.0 Snapshot. I verified this doesn't happen in a plain java javafx app using this example: http://tutorials.jenkov.com/javafx/directorychooser.html
b
on my Linux the problem is not reproducible, JavaFX 14
s
I dropped down to 14 and still got my bug. What version of Kotlin are you running?
b
1.3.72. I don't think the problem is in the Kotlin version
i used normal startup and not fast
Copy code
class Example : View() {
    override val root = pane {
        prefWidth = 600.0
        prefHeight = 500.0
        button("click") {
            action {
                val directoryChooser = DirectoryChooser()
                directoryChooser.showDialog(primaryStage)
            }
        }
    }
}

class TApp1 : App(Example::class)

fun main() {
    launch<TApp1>()
}
s
So when I run that you can see it starts to render in the dialog, before snapping to where it should be a few milliseconds later:
Could it be that it does that anyway, but my monitor is catching it? I have a 1ms refresh rate. Do you know what your monitor is?
b
I understood your problem, and saw it on Windows 10. Monitor frequency has nothing to do with it
1.4.10 - ok
s
So you've encountered this problem before? On only windows 10?
b
it seems to me that this is due to the JavaFX Runtime. Have you tried other runtimes? How do you launch the project?
s
Launching through gradle run task
b
So you've encountered this problem before? On only windows 10?
Yes. Well, I saw something like that for a long time, I don't remember the nuances
Launching through gradle run task
OS ?
s
My operating system? Windows 10
b
My: MANJARO Gnome
try JavaFX version 13 or 11, is there a problem?
s
will try now
same thing happening
its weird because it didn't happen with a pure java application
b
Alas, I still can't switch to Windows 10 and test it, I'll try to figure it out later. If you could debug the code and look for the problem?
s
Yeah I'll have a look although to be honest I'm not sure what to look for.
b
Just go through sequentially and understand at what stage the window appears in the upper corner of the screen, whether the TornadoFX code is involved in this
s
Alright I'll dive into it
Okay I narrowed it down. If the directory chooser does not have its initial directory set to something, it will do the bug. Otherwise adding in:
Copy code
directoryChooser.initialDirectory = File("src")
will prevent it from happening