In our application, we currently install an uncaught exception handler which will show a dialog.
This dialog contains the exception stracktrace and a button with the possibility to mail it.
Unfortunately, if an exception occurs in the layout phase (pulse), trying to show a dialog will result in an exception as we can't start a nested event loop in this situation.
This is because Dialog.showAndWait() checks that via Toolkit.getToolkit().canStartNestedEventLoop() and throws an exception with the message: "showAndWait is not allowed during animation or layout processing".
Therefore we need to delay it via Platform.runLater(..).
We do that by checking the same method as the dialog:
Toolkit.getToolkit().canStartNestedEventLoop()
If this method will return false, we will delay the dialog.
Currently, there is no (other) public way to check, whether it is safe right now to show a dialog other than the internal Toolkit class (com.sun.javafx.tk.Toolkit).Therefore I propose to add a method to the existing Platform class:Platform.canStartNestedEventLoop()which will like many other method just call Toolkit.getToolkit().canStartNestedEventLoop().For reference, see also:Platform.isNestedLoopRunning()
Platform.enterNestedEventLoop(..)
Platform.exitNestedEventLoop(..)-- Marius