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