Can we disable the close button for ImageWindow/StackWindow

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

Can we disable the close button for ImageWindow/StackWindow

vidya
Dear ImageJ,
 
I am using ImageJ programatically in my application. I do not want the user to have the option to close the ImagePlus window.  Is there any way to set this option programatically, i.e. to disable the 'close' option from the Imagewindow/Stackwindow 'frame'.
 
If anyone has a solution, please let me know. One other option I could think of is to extend ImageWindow/StackWindow and remove the frame decoration and use my window class in ImagePlus, but not sure if this is the right way and also if this will work smoothly.
 
Thanks for any help.
Vidya Chin
Reply | Threaded
Open this post in threaded view
|

Re: Can we disable the close button for ImageWindow/StackWindow

dscho
Dear Vidya Chin,

On Wed, 3 Aug 2011, vidya wrote:

> I am using ImageJ programatically in my application. I do not want the
> user to have the option to close the ImagePlus window.  Is there any way
> to set this option programatically, i.e. to disable the 'close' option
> from the Imagewindow/Stackwindow 'frame'.  If anyone has a solution,
> please let me know. One other option I could think of is to extend
> ImageWindow/StackWindow and remove the frame decoration and use my
> window class in ImagePlus, but not sure if this is the right way and
> also if this will work smoothly.

Actually, if you are subclassing ImageWindow anyway, you can just

        @Override
        public void windowClosing(WindowEvent e) {
                return; // prevent it from closing
        }

If you cannot do that, a quick and dirty way is to set the member variable
"closed" to true. It is dirty because you have to use reflection; this
member variable is protected.

Ciao,
Johannes
Reply | Threaded
Open this post in threaded view
|

Re: Can we disable the close button for ImageWindow/StackWindow

vidya
Thank you very much for the reply.  I will probably stick with the 1st solution and give that a try.
 
thanks,
Vidya Chin

From: Johannes Schindelin [via ImageJ] <[hidden email]>
To: vidya <[hidden email]>
Sent: Friday, August 5, 2011 9:31 AM
Subject: Re: Can we disable the close button for ImageWindow/StackWindow

Dear Vidya Chin,

On Wed, 3 Aug 2011, vidya wrote:

> I am using ImageJ programatically in my application. I do not want the
> user to have the option to close the ImagePlus window.  Is there any way
> to set this option programatically, i.e. to disable the 'close' option
> from the Imagewindow/Stackwindow 'frame'.  If anyone has a solution,
> please let me know. One other option I could think of is to extend
> ImageWindow/StackWindow and remove the frame decoration and use my
> window class in ImagePlus, but not sure if this is the right way and
> also if this will work smoothly.

Actually, if you are subclassing ImageWindow anyway, you can just

        @Override
        public void windowClosing(WindowEvent e) {
                return; // prevent it from closing
        }

If you cannot do that, a quick and dirty way is to set the member variable
"closed" to true. It is dirty because you have to use reflection; this
member variable is protected.

Ciao,
Johannes


If you reply to this email, your message will be added to the discussion below:
http://imagej.588099.n2.nabble.com/Can-we-disable-the-close-button-for-ImageWindow-StackWindow-tp6651283p6654979.html
To start a new topic under ImageJ, email [hidden email]
To unsubscribe from ImageJ, click here.