How do I modal FileChooser in JFXPanel?

I want to show a FileChooser dialog on top of an awt application that uses JFXPanel.

As the window for showOpenDialog, I use getWindow () for the scene set in this panel. But the file selection appears behind the application, and everything in the JFXPanel is still active (i.e. I can open more FileChooser dialogs, enter text, etc.).

I also found some example code with an extra step between the JFXPanel scene window and FileChooser that uses initModality. But there is no change in behavior.

Any ideas on how to open FileChooser as a modal dialog when the parent is JFXPanel?


source to share

1 answer


- blocking operation. It should stop capturing events in the JavaFX Application Thread. Since you are using swing there is also an Event Dispatch Thread. I would turn off the whole window before showOpenDialog()

and then turn it back on. Make sure you are accessing the JFXPanel from the JAT



All Articles