close window without selecting first

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

close window without selecting first

jvander
I am a long time user of ImageJ but my plug-in programming skills are rudimentary.  I typically
simply record a macro and convert to plug-in and dabble a bit with the details.

I am trying to close an image window without first selecting it.  Let's say I have two image windows
open named "image1" and "image2"

If the focus of attention is on image1 and I want to close image2 I do it as follows:

IJ.selectWindow("image2");
IJ.run("Close");

That works, but I'd prefer to do it in one command so that the focus stays on image1.

I guessed at

IJ.closeWindow("image2") among other things but have not figured it out yet.  Suggestions?

thanks

Joe vanderGracht
Reply | Threaded
Open this post in threaded view
|

Re: close window without selecting first

Michael Doube-2
Hi Joe

This works for me:

setBatchMode(true);
selectWindow("image2.tif");
run("Close");
setBatchMode(false);

Cheers,

Mike


around your code


Joe Vandergracht wrote:

> I am a long time user of ImageJ but my plug-in programming skills are rudimentary.  I typically
> simply record a macro and convert to plug-in and dabble a bit with the details.
>
> I am trying to close an image window without first selecting it.  Let's say I have two image windows
> open named "image1" and "image2"
>
> If the focus of attention is on image1 and I want to close image2 I do it as follows:
>
> IJ.selectWindow("image2");
> IJ.run("Close");
>
> That works, but I'd prefer to do it in one command so that the focus stays on image1.
>
> I guessed at
>
> IJ.closeWindow("image2") among other things but have not figured it out yet.  Suggestions?
>
> thanks
>
> Joe vanderGracht
>  

--
Michael Doube  BPhil BVSc MRCVS
PhD Student
Dental Institute
Queen Mary, University of London
New Rd
London  E1 1BB
United Kingdom

Phone +44 (0)20 7377 7000 ext 2681