enterNestedEventLoop as public API?

John Hendrikx hjohn at xs4all.nl
Tue Nov 12 22:15:49 PST 2013


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