Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Re-implement JavaFX showAndWait [closed]

I want to achieve the functionality of Stage.showAndWait() without using the method itself.

I have an application and I need a way of displaying something within the same stage and block the thread displaying the content until a button is pressed.

The thread displaying the content naturally needs to be tha JavaFX application thread - which of course won't handle the buttons as long as it is blocked.

Stage.showAndWait describes its inner workings as "This method temporarily blocks processing of the current event, and starts a nested event loop to handle other events." I see that the method calls "Toolkit.getToolkit().enterNestedEventLoop(this)", which is pretty implementation specific. Are there any other options? Is functionality like this exposed anywhere in the API?

Edit:
Since my question was misleading, I try to rephrase it more to the point from my current perspective:
Is there a public API for Toolkit.getToolkit().enterNestedEventLoop() and Toolkit.getToolkit().exitNestedEventLoop() ?

like image 468
taranion Avatar asked Nov 19 '25 13:11

taranion


1 Answers

For my rephrased question:

Is there a public API for Toolkit.getToolkit().enterNestedEventLoop() and Toolkit.getToolkit().exitNestedEventLoop() ?

Since then the API has been made public in:

javafx.application.Platform.enterNestedEventLoop()
like image 111
taranion Avatar answered Nov 22 '25 02:11

taranion



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!