enterNestedEventLoop as public API?
Tom Schindl
tom.schindl at bestsolution.at
Wed Nov 13 08:27:01 PST 2013
Currently the API requires to pass the same object to enter and exit how would your code work with multiple nested event loops?
Tom
Von meinem iPhone gesendet
> Am 13.11.2013 um 16:35 schrieb Stephen F Northover <steve.x.northover at oracle.com>:
>
> What is the difference?
>
> Dialog d = new Dialog() {
> public void onClose() {
> Platform.exitNestedEventLoop();
> }
> }
> Platform.enterNestedEventLoop();
>
>
> Steve
>
>> On 2013-11-13 5:28 AM, Tom Schindl wrote:
>> What bothers me with the API as it is today is that I have call
>> enter/exit, I would find it more easy to work with an API like:
>>
>> -------8<-------
>> WaitCondition c = new WaitCondition();
>> Dialog d = new Dialog() {
>> public void onClose() {
>> c.release();
>> }
>> }
>> Platform.spinNestedEventLoop(c);
>> ------->8-------
>>
>> Tom
>>
>>> On 13.11.13 11:18, Artem Ananiev wrote:
>>> I also think it's a good request for public API. In AWT/Swing, people
>>> had been using ugly workarounds with modal dialogs just to enter a
>>> nested event loop, until public java.awt API was finally provided:
>>>
>>> http://docs.oracle.com/javase/7/docs/api/java/awt/SecondaryLoop.html
>>>
>>> http://docs.oracle.com/javase/7/docs/api/java/awt/EventQueue.html#createSecondaryLoop()
>>>
>>>
>>> The same is here in JavaFX: unless Toolkit.enter/exitNestedEventLoop()
>>> is exposed at javafx.* level, people will have to workaround it by using
>>> Stage, or calling into com.sun.javafx.*, which is not good.
>>>
>>> Thanks,
>>>
>>> Artem
>>>
>>>> On 11/13/2013 10:15 AM, John Hendrikx wrote:
>>>> Hi List,
>>>>
>>>> Any chance that Toolkit.getToolkit().enterNestedEventLoop() will in the
>>>> future become public API?
>>>>
>>>> I'm currently using this to create Dialogs based on a Pane to avoid
>>>> creating Stages (which have the nice show and showAndWait
>>>> functionality). I duplicated this functionality in a Pane, allowing me
>>>> to create Dialogs on top of existing Scenes without creating a Stage,
>>>> and it makes use of the enterNestedEventLoop and exitNestedEventLoop
>>>> functions in com.sun.javafx.tk.Toolkit.
>>>>
>>>> The reason I'm avoiding the Stages is because they donot play well with
>>>> an application that never has the mouse or keyboard focus (my
>>>> application is fully remote controlled) -- creating a Stage, even one to
>>>> just show a Dialog, will cause Windows to try and attract the user's
>>>> attention by flashing its taskbar button (for which I filed a
>>>> bug/feature request) and this is undesired.
>>>>
>>>> Regards,
>>>> John
>>>>
>>>> (Here's a part of the DialogPane to show and close it:)
>>>>
>>>> public R showDialog(Scene scene, boolean synchronous) {
>>>> this.synchronous = synchronous;
>>>> this.scene = scene;
>>>> this.oldFocusOwner = scene.getFocusOwner();
>>>>
>>>> Parent root = scene.getRoot();
>>>>
>>>> stackPane.getChildren().add(root);
>>>> stackPane.getChildren().add(this);
>>>>
>>>> scene.setRoot(stackPane);
>>>>
>>>> requestFocus();
>>>>
>>>> if(synchronous) {
>>>> return (R)Toolkit.getToolkit().enterNestedEventLoop(this);
>>>> }
>>>>
>>>> return null;
>>>> }
>>>>
>>>> public void close() {
>>>> Parent originalRoot = (Parent)stackPane.getChildren().remove(0);
>>>>
>>>> scene.setRoot(originalRoot);
>>>> scene = null;
>>>>
>>>> if(oldFocusOwner != null) {
>>>> oldFocusOwner.requestFocus();
>>>> }
>>>>
>>>> if(synchronous) {
>>>> Toolkit.getToolkit().exitNestedEventLoop(this, getResult());
>>>> }
>>>> }
>
More information about the openjfx-dev
mailing list