Dear all!
I am developing a plugin which uses a Swing based GUI. The GUI will be rather complex witch is why I prefer to use Swing and Netbeans for GUI design ( I am running Mac OS X Lion, and ImageJ 1.46d). Some operations will have to rely on user interaction with ImageJ commands and then return execution to the plugin ( i.e. drawing on images etc) . When I try to use the WaitForUserDialog class the, The WaitForUserDialog shows the window with ok button but not the message text and none of the other parts of the plugin or ImageJ is working (can't quit the imagej instance either). The way I have implemented the GUI is by first having a class that implements Plugin. Then that class creates a object of the class that implements the Swing GUI and sets it visible. I have tried to invoke the WaitForUserDialog from the class that implements plugin and and it works fine, I have tried other operations from the GUI object, for instance SaveChangesDialog and they work as expected. What is the best way to implement a advanced GUI to work in ImageJ ? With best regards, Tomas |
Hi Thomas,
if everything else works well, why not simply write your own WaitForUserDialog with Swing components? Another option would be trying the old version of it, which does not have all the bells&whistles of the version in ImageJ: http://imagejdocu.tudor.lu/doku.php?id=plugin:utilities:wait_for_user:start Michael _________________________________________________________________ On Sun, January 8, 2012 19:18, Tomas Karlsson wrote: > Dear all! > > I am developing a plugin which uses a Swing based GUI. The GUI will be > rather complex witch is why I prefer to use Swing and Netbeans for GUI > design ( I am running Mac OS X Lion, and ImageJ 1.46d). Some operations > will have to rely on user interaction with ImageJ commands and then return > execution to the plugin ( i.e. drawing on images etc) . When I try to use > the WaitForUserDialog class the, The WaitForUserDialog shows the window > with ok button but not the message text and none of the other parts of the > plugin or ImageJ is working (can't quit the imagej instance either). > > The way I have implemented the GUI is by first having a class that > implements Plugin. Then that class creates a object of the class that > implements the Swing GUI and sets it visible. > > I have tried to invoke the WaitForUserDialog from the class that > implements plugin and and it works fine, I have tried other operations > from the GUI object, for instance SaveChangesDialog and they work as > expected. What is the best way to implement a advanced GUI to work in > ImageJ ? > > With best regards, > > Tomas |
In reply to this post by Tomas Karlsson-2
Thanks for the replies. Yep - it was executing from event-dispatch thread. Solved by using a SwingWorker.
Best regards, Tomas 8 jan 2012 kl. 22:30 skrev Rasband, Wayne (NIH/NIMH) [E]: > Dear Tomas, > > I suspect this is a threading issue. Are you calling WaitForUserDialog from the event dispatch thread? That could cause the problems you are seeing. > > Best regard, > > -wayne > > > On Jan 8, 2012, at 1:18 PM, Tomas Karlsson wrote: > >> Dear all! >> >> I am developing a plugin which uses a Swing based GUI. The GUI will be rather complex witch is why I prefer to use Swing and Netbeans for GUI design ( I am running Mac OS X Lion, and ImageJ 1.46d). Some operations will have to rely on user interaction with ImageJ commands and then return execution to the plugin ( i.e. drawing on images etc) . When I try to use the WaitForUserDialog class the, The WaitForUserDialog shows the window with ok button but not the message text and none of the other parts of the plugin or ImageJ is working (can't quit the imagej instance either). >> >> The way I have implemented the GUI is by first having a class that implements Plugin. Then that class creates a object of the class that implements the Swing GUI and sets it visible. >> >> I have tried to invoke the WaitForUserDialog from the class that implements plugin and and it works fine, I have tried other operations from the GUI object, for instance SaveChangesDialog and they work as expected. What is the best way to implement a advanced GUI to work in ImageJ ? >> >> With best regards, >> >> Tomas > |
Tomas, Wayne
I think I am running into the same problem with the WaitForUserDialog that this thread discussed, and I assume the same solution might apply. However, since I am not well versed in Swing could you provide an example of how to used the SwingWorker to get this dialog off the event-despatch thread? From what I can see, SwingWorker provides a way to move intensive calcs (updating) into the background, rather than the window of the dialog itself, but maybe this is a way of 'inverting' the logic... In my particular case I call a method my_pause() to pause the thread by capturing a double mouse click on a dispayed image and then instantiate a WaitForUserDialog inside my_pause(). The way I initially tried gave me exactly the same symptoms Tomas described. Putting a SwingWorker to handle the WaitForUserDialog in my_pause() was successful in that the dialog and button were now visible, but the button event did not operate to close the window and continue. As an alternative I've been trying to use a non-modal generic dialog to get the pause but haven't had much success with this approach either If there's any way I can leverage what you already came up with I'd be most grateful! Thanks Chris H |
Free forum by Nabble | Edit this page |