From 935523a8c58efced1c0845bd60e08e2acb9e5aee Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 2 May 2012 01:20:46 +0200 Subject: NEWT API Change 'WindowClosingProtocol': Use 'enum WindowClosingMode' instead of static final int values. --- .../nativewindow/awt/AWTWindowClosingProtocol.java | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'src/nativewindow/classes/com/jogamp') diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java index df32f5942..d78b4ac15 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java @@ -43,7 +43,7 @@ public class AWTWindowClosingProtocol implements WindowClosingProtocol { private Runnable closingOperation; private volatile boolean closingListenerSet = false; private Object closingListenerLock = new Object(); - private int defaultCloseOperation = DISPOSE_ON_CLOSE; + private WindowClosingMode defaultCloseOperation = WindowClosingMode.DISPOSE_ON_CLOSE; private boolean defaultCloseOperationSetByUser = false; public AWTWindowClosingProtocol(Component comp, Runnable closingOperation) { @@ -54,9 +54,9 @@ public class AWTWindowClosingProtocol implements WindowClosingProtocol { class WindowClosingAdapter extends WindowAdapter { @Override public void windowClosing(WindowEvent e) { - int op = AWTWindowClosingProtocol.this.getDefaultCloseOperation(); + final WindowClosingMode op = AWTWindowClosingProtocol.this.getDefaultCloseOperation(); - if( DISPOSE_ON_CLOSE == op ) { + if( WindowClosingMode.DISPOSE_ON_CLOSE == op ) { // we have to issue this call right away, // otherwise the window gets destroyed closingOperation.run(); @@ -111,27 +111,23 @@ public class AWTWindowClosingProtocol implements WindowClosingProtocol { /** * - * @return the user set close operation if set by {@link #setDefaultCloseOperation(int) setDefaultCloseOperation(int)}, + * @return the user set close operation if set by {@link #setDefaultCloseOperation(WindowClosingMode) setDefaultCloseOperation(int)}, * otherwise return the AWT/Swing close operation value translated to * a {@link WindowClosingProtocol} value . */ - public final int getDefaultCloseOperation() { - int op = -1; + public final WindowClosingMode getDefaultCloseOperation() { synchronized(closingListenerLock) { if(defaultCloseOperationSetByUser) { - op = defaultCloseOperation; + return defaultCloseOperation; } } - if(0 <= op) { - return op; - } // User didn't determine the behavior, use underlying AWT behavior return AWTMisc.getNWClosingOperation(comp); } - public final int setDefaultCloseOperation(int op) { + public final WindowClosingMode setDefaultCloseOperation(WindowClosingMode op) { synchronized(closingListenerLock) { - int _op = defaultCloseOperation; + final WindowClosingMode _op = defaultCloseOperation; defaultCloseOperation = op; defaultCloseOperationSetByUser = true; return _op; -- cgit v1.2.3