Re: Can we disable the close button for ImageWindow/StackWindow
Posted by dscho on Aug 05, 2011; 1:28am
URL: http://imagej.273.s1.nabble.com/Can-we-disable-the-close-button-for-ImageWindow-StackWindow-tp3683604p3683605.html
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