aboutsummaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes/com/jogamp
diff options
context:
space:
mode:
Diffstat (limited to 'src/nativewindow/classes/com/jogamp')
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java31
1 files changed, 14 insertions, 17 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java
index 27275c6e0..aadecb455 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java
@@ -40,11 +40,11 @@ import jogamp.nativewindow.awt.AWTMisc;
public class AWTWindowClosingProtocol implements WindowClosingProtocol {
- private Component comp;
- private Runnable closingOperationClose;
- private Runnable closingOperationNOP;
- private boolean closingListenerSet = false;
- private Object closingListenerLock = new Object();
+ private final Component comp;
+ private Window listenTo;
+ private final Runnable closingOperationClose;
+ private final Runnable closingOperationNOP;
+ private final Object closingListenerLock = new Object();
private WindowClosingMode defaultCloseOperation = WindowClosingMode.DISPOSE_ON_CLOSE;
private boolean defaultCloseOperationSetByUser = false;
@@ -55,6 +55,7 @@ public class AWTWindowClosingProtocol implements WindowClosingProtocol {
*/
public AWTWindowClosingProtocol(Component comp, Runnable closingOperationClose, Runnable closingOperationNOP) {
this.comp = comp;
+ this.listenTo = null;
this.closingOperationClose = closingOperationClose;
this.closingOperationNOP = closingOperationNOP;
}
@@ -86,13 +87,12 @@ public class AWTWindowClosingProtocol implements WindowClosingProtocol {
*/
public final boolean addClosingListener() throws IllegalStateException {
synchronized(closingListenerLock) {
- if(closingListenerSet) {
+ if(null != listenTo) {
throw new IllegalStateException("WindowClosingListener already set");
}
- final Window w = AWTMisc.getWindow(comp);
- if(null!=w) {
- w.addWindowListener(windowClosingAdapter);
- closingListenerSet = true;
+ listenTo = AWTMisc.getWindow(comp);
+ if(null!=listenTo) {
+ listenTo.addWindowListener(windowClosingAdapter);
return true;
}
}
@@ -101,13 +101,10 @@ public class AWTWindowClosingProtocol implements WindowClosingProtocol {
public final boolean removeClosingListener() {
synchronized(closingListenerLock) {
- if(closingListenerSet) {
- final Window w = AWTMisc.getWindow(comp);
- if(null!=w) {
- w.removeWindowListener(windowClosingAdapter);
- closingListenerSet = false;
- return true;
- }
+ if(null != listenTo) {
+ listenTo.removeWindowListener(windowClosingAdapter);
+ listenTo = null;
+ return true;
}
}
return false;