aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt
diff options
context:
space:
mode:
Diffstat (limited to 'src/newt')
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/awt/AWTCanvas.java24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/newt/classes/com/jogamp/newt/impl/awt/AWTCanvas.java b/src/newt/classes/com/jogamp/newt/impl/awt/AWTCanvas.java
index bbf75798e..9b0ec6907 100644
--- a/src/newt/classes/com/jogamp/newt/impl/awt/AWTCanvas.java
+++ b/src/newt/classes/com/jogamp/newt/impl/awt/AWTCanvas.java
@@ -37,12 +37,10 @@ import com.jogamp.newt.Window;
import java.awt.Canvas;
import java.awt.GraphicsDevice;
-import java.awt.GraphicsEnvironment;
import java.awt.GraphicsConfiguration;
import javax.media.nativewindow.*;
import javax.media.nativewindow.awt.*;
-import com.jogamp.newt.impl.Debug;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
@@ -102,6 +100,28 @@ public class AWTCanvas extends Canvas {
}
}
+ public void removeNotify() {
+ try {
+ dispose();
+ } finally {
+ super.removeNotify();
+ }
+ }
+
+ private void dispose() {
+ if(null != awtConfig) {
+ AbstractGraphicsDevice adevice = awtConfig.getNativeGraphicsConfiguration().getScreen().getDevice();
+ String adeviceMsg=null;
+ if(Window.DEBUG_IMPLEMENTATION) {
+ adeviceMsg = adevice.toString();
+ }
+ boolean closed = adevice.close();
+ if(Window.DEBUG_IMPLEMENTATION) {
+ System.err.println("AWTCanvas.dispose(): closed GraphicsDevice: "+adeviceMsg+", result: "+closed);
+ }
+ }
+ }
+
/**
* Overridden to choose a GraphicsConfiguration on a parent container's
* GraphicsDevice because both devices