"WaitForUserDialog" doesn't work in my "ActionListener" plugin

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

"WaitForUserDialog" doesn't work in my "ActionListener" plugin

Ghislain BUGNICOURT-2
Dear all,

My goal is to use "WaitForUserDialog" in a plugin that gathers my  
self-made processes.
I tried to simplify my plugin in the attached document ("_Truc", just  
add ".java" to use). The first occurence of "WaitForUserDialog" works  
fine. The second one, whithin an "actionPerformed", blocks ImageJ  
completely.
NB : The only way I found to leave ImageJ after the bug occured was  
the famous "kill -9" command (or killing the java process when I  
tried on windows).

I guess the problem comes from the fact that two "actionPerformed"  
are active at the same time, but I really can't go deeper...
Could you help me use such a non-modal dialog when clicking a button  
in my plugin ?
Thanks a lot
Ghislain Bugnicourt

PS : I use ImageJ 1.43i. The problem also occurs using  
"NonBlockingGenericDialog".



>



_Truc.txt (643 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: "WaitForUserDialog" doesn't work in my "ActionListener" plugin

dscho
Hi,

On Wed, 28 Oct 2009, Ghislain BUGNICOURT wrote:

> My goal is to use "WaitForUserDialog" in a plugin that gathers my
> self-made processes. I tried to simplify my plugin in the attached
> document ("_Truc", just add ".java" to use). The first occurence of
> "WaitForUserDialog" works fine. The second one, whithin an
> "actionPerformed", blocks ImageJ completely.

The actionPerformed() method is called in the event handling thread.  So I
guess the problem can be fixed by launching the dialog from a newly
started thread.

Hth,
Dscho
Reply | Threaded
Open this post in threaded view
|

Re: "WaitForUserDialog" doesn't work in my "ActionListener" plugin

Ghislain BUGNICOURT-2
Hi,
Now it works well, thank you !

Details : this method...
> public void actionPerformed(ActionEvent e) {
> new WaitForUserDialog("CCCC", "DDDD").show();
> }

...was changed into :
> public void actionPerformed(ActionEvent e) {
> Thread waitDialog = new Thread(new Runnable() {
> public void run() {
> new WaitForUserDialog("CCCC", "DDDD").show();
> }
> });
> waitDialog.start();
> }

Regards,
Ghislain Bugnicourt

Le 28 oct. 09 à 14:13, Johannes Schindelin a écrit :

> Hi,
>
> On Wed, 28 Oct 2009, Ghislain BUGNICOURT wrote:
>
>> My goal is to use "WaitForUserDialog" in a plugin that gathers my
>> self-made processes. I tried to simplify my plugin in the attached
>> document ("_Truc", just add ".java" to use). The first occurence of
>> "WaitForUserDialog" works fine. The second one, whithin an
>> "actionPerformed", blocks ImageJ completely.
>
> The actionPerformed() method is called in the event handling  
> thread.  So I
> guess the problem can be fixed by launching the dialog from a newly
> started thread.
>
> Hth,
> Dscho