Login  Register

Wait for user / NonBlockingGenericDialog

Posted by Influenza on Oct 22, 2013; 4:21pm
URL: http://imagej.273.s1.nabble.com/Wait-for-user-NonBlockingGenericDialog-tp5005270.html

Hy everyone,

I have a Problem with my PlugIn that has been solved in different ways yet, but all of the solutions don't work for me.

I want the User after opening an Image to make a point selection and I want the PlugIn to wait until that has happend.

If I do something like:

        ...IJ.setTool("point");
        nbgd=new NonBlockingGenericDialog("Fixpoint required!");
        nbgd.addMessage("For further please tag fixpoint and enter OK afterwards");
        nbgd.showDialog();
        rm.runCommand("Add");...

The Plugin continues and the Manager shows up empty with the dialog displayed. But the Dialog such as ImageJ itselve can't be quit anymore.

Then I read about the WaitForUser Dialog. Doing:

        ...IJ.setTool("point");
        new WaitForUserDialog("...","...");
        rm.runCommand("Add");...

the same happens with the difference that no message is displayed in the dialog. Here I read about solving the problem by outsourcing the Dialog in a new Thread:

        ...IJ.setTool("point");
        wfUser("...","...");
        rm.runCommand("Add");...

        public void wfUser(final String title, final String message){
       
               
  Thread waitDialog = new Thread(new Runnable() {
                         public void run() {
                                 new WaitForUserDialog(title,message).show();
                        }
                });
        waitDialog.start();

        }

but the Plugin still don't waits until the user made the selection.
I'm glad for every hint or solution!

Thanks & best regards
Steve