Newt and dispose()

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Newt and dispose()

elect
I encapsulated glWindows within a NewtCanvasAWT and in turn in a JFrame..

I noticed that whenever I click on the X to close it, dispose() is not called

Is this normal or is one problem of mine?
Reply | Threaded
Open this post in threaded view
|

Re: Newt and dispose()

gouessej
Administrator
Hi

Use a WindowListener and call dispose() in the correct method by yourself. Maybe Sven could explain what the expected behavior is.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Newt and dispose()

elect
gouessej wrote
Hi

Use a WindowListener and call dispose() in the correct method by yourself. Maybe Sven could explain what the expected behavior is.
Calling destroy() on the NewtCanvasAWT seems working, it calls in turn dispose(). Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Newt and dispose()

gouessej
Administrator
You're welcome but I would like to know whether this is really the right thing to do. It works, it's fine :)
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Newt and dispose()

Sven Gothel
Administrator
In reply to this post by elect
On 12/18/2013 04:09 PM, elect [via jogamp] wrote:
>     gouessej wrote
>     Hi
>
>     Use a WindowListener and call dispose() in the correct method by yourself.
>     Maybe Sven could explain what the expected behavior is.
>
> Calling destroy() on the NewtCanvasAWT seems working, it calls in turn
> dispose(). Thanks


We attach an instance of AWTWindowClosingProtocol
to NewtCanvasAWT, with:
   ...
   * @param closingOperationClose mandatory closing operation, triggered if windowClosing and {@link WindowClosingMode#DISPOSE_ON_CLOSE}
   * @param closingOperationNOP optional closing operation, triggered if windowClosing and {@link WindowClosingMode#DO_NOTHING_ON_CLOSE}
   */
  public AWTWindowClosingProtocol(Component comp,
     Runnable closingOperationClose, Runnable closingOperationNOP) ...

The 'default closing operation' is initially fetched from the
NewtCanvasAWT's JFrame, if exists, or WindowConstants.DO_NOTHING_ON_CLOSE.

Users can override NewtCanvasAWT's 'default closing operation'.

NewtCanvasAWT's closing operations are:

WindowConstants.DO_NOTHING_ON_CLOSE (closingOperationClose):
  - detach the NEWT window from NewtCanvasAWT and
  - send NEWT WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY

WindowClosingMode.DISPOSE_ON_CLOSE (closingOperationNOP):
  - send NEWT WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY

Hence, the NEWT window can still be used by default after the AWT component
has been disposed/closed.

To dispose the Newt child w/ the AWT window, simply add a NEWT window listener
and issue dispose on the NEWT window.

Maybe not as intuitive, however still quite flexible.


~Sven



signature.asc (911 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Newt and dispose()

elect
I cannot add any window listener on the newtCanvasAWT, I dont have any method. But I do have on the glWindow
Reply | Threaded
Open this post in threaded view
|

Re: Newt and dispose()

gouessej
Administrator
Yes, use a Newt WindowListener and override windowDestroyNotify.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Newt and dispose()

elect
so

glWindow.addWindowListener(new WindowAdapter() {

   @Override
   public void windowDestroyNotify(WindowEvent windowEvent){

   }
});


I dont have any dispose on the glWindow, should I call directly the dispose(GLAutoDrawable drawable)?
Reply | Threaded
Open this post in threaded view
|

Re: Newt and dispose()

gouessej
Administrator
Why not calling destroy()?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Newt and dispose()

elect
Ok
Reply | Threaded
Open this post in threaded view
|

Re: Newt and dispose()

Sven Gothel
Administrator
In reply to this post by Sven Gothel
Sven Gothel wrote
NewtCanvasAWT's closing operations are:

WindowConstants.DO_NOTHING_ON_CLOSE (closingOperationClose):
  - detach the NEWT window from NewtCanvasAWT and
  - send NEWT WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY

WindowClosingMode.DISPOSE_ON_CLOSE (closingOperationNOP):
  - send NEWT WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY
I have confused the 2 above operations, they are of course vice versa:

NewtCanvasAWT's closing operations are:

WindowClosingMode.DISPOSE_ON_CLOSE (closingOperationClose):
  - detach the NEWT window from NewtCanvasAWT and
  - send NEWT WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY

WindowConstants.DO_NOTHING_ON_CLOSE (closingOperationNOP):
  - send NEWT WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY