Re: Macro run problem?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Macro run problem?

Amelie Marzin
Hi,

I finally found the problem (but not the entire solution).

I created a java toolbar, and my macros are launched in actionPerformed(ActionEvent e) (when the user select a button).

When I tried to launch this way a macro which contains a getCursorLoc(x,y,z,flags) OR a plugin which implements MouseListener, the entire application froze.

I noticed that if I launch my macro (or my plugin) from the run() method of my toolbar, it works !

So I am currently writing a solution with threads. It's OK when I just launch the macro or the plugin, but if I want to do something after the execution, I still have difficulties to wait for my threads to end... I will persist !
Reply | Threaded
Open this post in threaded view
|

Re: Macro run problem?

Amelie Marzin
I have something you can try.

I recreated my problem with Mouse_Listener.java :
I just added the following :
new WaitForUserDialog("Do something, then click OK").show();
at differents places.

Just add this line first in run(), then in mousePressed(MouseEvent e).
Please tell me if you have the same problem as me : in the first case, it's ok ; in the second, everything freezes.

And if you have any idea ... ;)

Thanks,

Amélie
Reply | Threaded
Open this post in threaded view
|

Re: Macro run problem?

Nathaniel Ryckman
Someone else had this problem as well:

http://imagej.588099.n2.nabble.com/quot-WaitForUserDialog-quot-doesn-t-work-in-my-quot-ActionListener-quot-plugin-td3905258.html

You cannot launch a GUI from an event action handler:

http://publib.boulder.ibm.com/infocenter/p8docs/v4r5m1/index.jsp?topic=%2Fcom.ibm.p8.doc%2Fdeveloper_help%2Fcontent_engine_api%2Fguide%2Fserver_concepts.htm

Amelie Marzin wrote
I have something you can try.

I recreated my problem with Mouse_Listener.java :
I just added the following :
new WaitForUserDialog("Do something, then click OK").show();
at differents places.

Just add this line first in run(), then in mousePressed(MouseEvent e).
Please tell me if you have the same problem as me : in the first case, it's ok ; in the second, everything freezes.

And if you have any idea ... ;)

Thanks,

Amélie
Reply | Threaded
Open this post in threaded view
|

Re: Macro run problem?

Nathaniel Ryckman
In reply to this post by Amelie Marzin
Scratch that last post....

I guess I'm way too rusty to help you with threads. I do know that this wait command in the show command of the WaitForUserDialog class is what is responsible for freezing things though....

public void show() {
                super.show();
                synchronized(this) {  //wait for OK
                        IJ.log("test");
                       
                        try {wait();}
                        catch(InterruptedException e) {return;}
                }
        }

Amelie Marzin wrote
I have something you can try.

I recreated my problem with Mouse_Listener.java :
I just added the following :
new WaitForUserDialog("Do something, then click OK").show();
at differents places.

Just add this line first in run(), then in mousePressed(MouseEvent e).
Please tell me if you have the same problem as me : in the first case, it's ok ; in the second, everything freezes.

And if you have any idea ... ;)

Thanks,

Amélie