enterNestedEventLoop as public API?
Anthony Petrov
anthony.petrov at oracle.com
Wed Nov 13 09:00:48 PST 2013
Thanks.
--
best regards,
Anthony
On 11/13/2013 08:51 PM, John Hendrikx wrote:
> Hi Anthony,
>
> I just filed https://javafx-jira.kenai.com/browse/RT-34268 for this.
>
> --John
>
> On 13/11/2013 17:42, Anthony Petrov wrote:
>> Hi John,
>>
>> Please file an RFE to introduce this public API.
>>
>> --
>> best regards,
>> Anthony
>>
>> On 11/13/2013 08:35 PM, John Hendrikx wrote:
>>> On 13/11/2013 16:35, Stephen F Northover wrote:
>>>> What is the difference?
>>>>
>>>> Dialog d = new Dialog() {
>>>> public void onClose() {
>>>> Platform.exitNestedEventLoop();
>>>> }
>>>> }
>>>> Platform.enterNestedEventLoop();
>>> I find the current API to work well, it is just in the wrong package
>>> tree :)
>>>
>>> Considering I didn't know about nested event loops before, I find the
>>> solution quite elegant -- leave the old event loop on the call stack,
>>> and start a fresh one that can be exited to continue again where the
>>> main event loop was halted -- it's almost like a 2nd thread gets
>>> started, but there isn't :)
>>>
>>> --John
>>>
>>>>
>>>> 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