From fa1d211c9658ce209f411e559333da0e2fccd402 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 23 Nov 2013 16:59:27 +0100 Subject: JOGLNewtAppletBase's add/remove 'reparentHome WindowListener' at start()/stop() --- .../jogamp/newt/awt/applet/JOGLNewtAppletBase.java | 41 +++++++++++----------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'src/newt/classes/com') diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java index 2c4f25804..4a2878e3a 100644 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java @@ -162,26 +162,6 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { public void init(ThreadGroup tg, final GLWindow glWindow) { isValid = false; this.glWindow = glWindow; - this.glWindow.addWindowListener(new WindowAdapter() { - // Closing action: back to parent! - @Override - public void windowDestroyNotify(WindowEvent e) { - if( isValid() && WindowClosingMode.DO_NOTHING_ON_CLOSE == glWindow.getDefaultCloseOperation() && - null == glWindow.getParent() && null != awtParent && 0 != awtParent.getWindowHandle() ) - { - Thread.dumpStack(); - // we may be called directly by the native EDT - new Thread(new Runnable() { - @Override - public void run() { - if( glWindow.isNativeValid() && null != awtParent && 0 != awtParent.getWindowHandle() ) { - glWindow.reparentWindow(awtParent); - } - } - }).start(); - } - } } ); - glEventListener = createInstance(glEventListenerClazzName); if(null == glEventListener) { return; @@ -226,17 +206,38 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { isValid = true; } + private final WindowListener reparentHomeListener = new WindowAdapter() { + // Closing action: back to parent! + @Override + public void windowDestroyNotify(WindowEvent e) { + if( isValid() && WindowClosingMode.DO_NOTHING_ON_CLOSE == glWindow.getDefaultCloseOperation() && + null == glWindow.getParent() && null != awtParent && 0 != awtParent.getWindowHandle() ) + { + // we may be called directly by the native EDT + new Thread(new Runnable() { + @Override + public void run() { + if( glWindow.isNativeValid() && null != awtParent && 0 != awtParent.getWindowHandle() ) { + glWindow.reparentWindow(awtParent); + } + } + }).start(); + } + } }; + public void start() { if(isValid) { glWindow.setVisible(true); glWindow.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); glAnimator.start(); awtParent = glWindow.getParent(); + glWindow.addWindowListener(reparentHomeListener); } } public void stop() { if(null!=glAnimator) { + glWindow.removeWindowListener(reparentHomeListener); glAnimator.stop(); glWindow.setVisible(false); } -- cgit v1.2.3