Closing a Results Table

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

Closing a Results Table

Thomas Sadowski
Hello all,



Does anyone know the syntax required to close the results table in an ImageJ
application???? Using the following:

TextPanel tp = IJ.getTextPanel();
tp.hide();


Merely clears the text in the Results. I wish to get rid of the entire
window.

Thank you in advance.


Thomas Sadowski
Southern Connecticut State University
Reply | Threaded
Open this post in threaded view
|

Re: Closing a Results Table

Parker Seidel
Hi,

Looking at the Source Code for the WindowManager.closeAll(), I think I
found the solution.  If you've created a ResultsTable RT and then
called RT.show("Title"), the results table will be displayed as a
window named "Title."  To close this window, you need to use the
WindowManager:

     Frame FR = WindowManager.getFrame("Title");
     if (FR instanceof TextWindow)
             ((TextWindow)FR).close();
      else if (FR instanceof PlugInFrame)
            ((PlugInFrame)FR).close();

In the case of the Results Table, its Frame is a TextWindow, so you
don't need the second else if.  To close the default Results table,
just change "Title" into "Results"

-Parker Seidel


On 8/11/05, Thomas Sadowski <[hidden email]> wrote:

> Hello all,
>
>
>
> Does anyone know the syntax required to close the results table in an ImageJ
> application???? Using the following:
>
> TextPanel tp = IJ.getTextPanel();
> tp.hide();
>
>
> Merely clears the text in the Results. I wish to get rid of the entire
> window.
>
> Thank you in advance.
>
>
> Thomas Sadowski
> Southern Connecticut State University
>
Reply | Threaded
Open this post in threaded view
|

Re: Closing a Results Table

Wayne Rasband
In reply to this post by Thomas Sadowski
> Does anyone know the syntax required to close the results
> table in an ImageJ application???? Using the following:
>
> TextPanel tp = IJ.getTextPanel();
> tp.hide();
>
> Merely clears the text in the Results. I wish to
> get rid of the entire window.

Enable the macro recorder (Plugins>Macros>Record), select "Results" in
the Window menu, select "Close" in the File menu, and the following is
recorded:

     selectWindow("Results");
     run("Close");

Run this macro and you will see that it closes the Results window.
Unfortunately, it generates an error if the Results window is not open.
You can get around this by testing to see if the Results window is
open.

     if (isOpen("Results")) {
         selectWindow("Results");
         run("Close");
    }

Convert this macro to Java by adding "IJ." to the function calls:

     if (IJ.isOpen("Results")) {
         IJ.selectWindow("Results");
         IJ.run("Close");
    }

Unfortunately, there is no isOpen() method in the IJ class. Look up the
code that implements isOpen() in Functions.java and you will see it
works by calling WindowManager.getFrame(title), so we need to change
the code to:

     if (WindowManager.getFrame("Results")!=null) {
         IJ.selectWindow("Results");
         IJ.run("Close");
    }

Another work around would be to run the macro using IJ.runMacro():

     IJ.runMacro("if (isOpen('Results')) {selectWindow('Results');
run('Close');}");

-wayne