How to set focus to s specific image in a plugin

Posted by Lambacher, Armin on
URL: http://imagej.273.s1.nabble.com/How-to-set-focus-to-s-specific-image-in-a-plugin-tp5018020.html

Hello Everybody,

I do some evaluations on an image and upon certain keypresses a result is added to a ResultsTable. After that I want to get the focus back to the original image again. I tried to understand the logics of the WindowManager, but it seems that I fail in that respect.

Here’s a code snippet, the whole code is to big to attach. The function “_createBleachingResult()” will add the current result to the ResultsTable (creating the ResultsTable upon first call). After adding the result I call the show() function of the table to update the screen representation. Then I try to get the focus back to the _sourceImage. When debugging, the content of win seems resonable, as the debugger shows the correct title of the _sourceImage in the win variable. But neither “setCurrentWindow” nor “setWindow” bring the focus back to the _sourceImage.



                _createBleachingResult(bd);
               
                if( _bleachingResultsTable != null )  
                {
                        _bleachingResultsTable.show("Bleachings");
                }
               
                // after bleaching is added, we try to set focus to the image again
               
                ImageWindow win = ij.WindowManager.getImage(_sourceImage.getTitle()).getWindow();

                IJ.wait(100);
               
                ij.WindowManager.setCurrentWindow(win);

                ij.WindowManager.setWindow(ij.WindowManager.getWindow(_sourceImage.getTitle()));




Can anybody please enlighten me?

Best

Armin


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html