-
Enhancement
-
Resolution: Fixed
-
P4
-
jfx21
-
b09
-
generic
-
generic
The JavaFX API lacks an useful method to find out whether it is safe to start a nested event loop or not.
One example where this method is useful is the Dialog class. (Another one is printing)
When calling dialog.showAndWait(), a check is performed:
Toolkit.getToolkit().canStartNestedEventLoop(), which will throw an exception if false.
The problem here is, that developers may wish to check this before calling showAndWait() but since the Toolkit is private sun api, it is not recommended to do so.
Following the other nested event loop method, I propse to add Platform.canStartNestedEventLoop(), which is delegating to the Toolkit (just like the other methods).
See also my mail in the mailing list from September 2022 https://mail.openjdk.org/pipermail/openjfx-dev/2022-September/035867.html
Existing public API for nested event loops:
- Platform.isNestedLoopRunning()
- Platform.enterNestedEventLoop(..)
- Platform.exitNestedEventLoop(..)
Situations where canStartNestedEventLoop() is returning false:
- When showing a dialog in a Timeline Keyframe
- When showing a dialog when still in the layout phase
-> When the pulse is running, it is not safe to show a dialog
Currently possible workaround:
- Toolkit.getToolkit().canStartNestedEventLoop()
- try (dialog.showAndWait()) catch(IllegalStateException)
One example where this method is useful is the Dialog class. (Another one is printing)
When calling dialog.showAndWait(), a check is performed:
Toolkit.getToolkit().canStartNestedEventLoop(), which will throw an exception if false.
The problem here is, that developers may wish to check this before calling showAndWait() but since the Toolkit is private sun api, it is not recommended to do so.
Following the other nested event loop method, I propse to add Platform.canStartNestedEventLoop(), which is delegating to the Toolkit (just like the other methods).
See also my mail in the mailing list from September 2022 https://mail.openjdk.org/pipermail/openjfx-dev/2022-September/035867.html
Existing public API for nested event loops:
- Platform.isNestedLoopRunning()
- Platform.enterNestedEventLoop(..)
- Platform.exitNestedEventLoop(..)
Situations where canStartNestedEventLoop() is returning false:
- When showing a dialog in a Timeline Keyframe
- When showing a dialog when still in the layout phase
-> When the pulse is running, it is not safe to show a dialog
Currently possible workaround:
- Toolkit.getToolkit().canStartNestedEventLoop()
- try (dialog.showAndWait()) catch(IllegalStateException)
- csr for
-
JDK-8302576 Public API for Toolkit.canStartNestedEventLoop()
- Closed
- relates to
-
JDK-8090865 Please make Toolkit.enterNestedEventLoop and exitNestedEventLoop public API
- Resolved