summaryrefslogtreecommitdiff
path: root/java/awt/Window.java
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2006-10-29 22:49:21 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2006-10-29 22:49:21 +0000
commite36d2a50b5a1a677c7ecaf926e73a5dac386c1ef (patch)
tree9649a7997f35624c829eccad8c84c84e9c8e3fb9 /java/awt/Window.java
parentbe24db70d4ff66302f560e12913f5b71acf3c12c (diff)
downloadclasspath-e36d2a50b5a1a677c7ecaf926e73a5dac386c1ef.tar.gz
2006-10-29 Andrew John Hughes <gnu_andrew@member.fsf.org>
* Merge of HEAD --> generics for 2006/10/04-2006/10/29.
Diffstat (limited to 'java/awt/Window.java')
-rw-r--r--java/awt/Window.java168
1 files changed, 110 insertions, 58 deletions
diff --git a/java/awt/Window.java b/java/awt/Window.java
index 7a3092f81..41dff5577 100644
--- a/java/awt/Window.java
+++ b/java/awt/Window.java
@@ -362,15 +362,15 @@ public class Window extends Container implements Accessible
component[i].removeNotify();
this.removeNotify();
- // Post WINDOW_CLOSED from here.
- if (windowListener != null
- || (eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0)
- {
- WindowEvent ev = new WindowEvent(this,
- WindowEvent.WINDOW_OPENED);
- Toolkit tk = Toolkit.getDefaultToolkit();
- tk.getSystemEventQueue().postEvent(ev);
- }
+ // Post WINDOW_CLOSED from here.
+ if (windowListener != null
+ || (eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0)
+ {
+ WindowEvent ev = new WindowEvent(this,
+ WindowEvent.WINDOW_CLOSED);
+ Toolkit tk = Toolkit.getDefaultToolkit();
+ tk.getSystemEventQueue().postEvent(ev);
+ }
}
}
@@ -498,7 +498,11 @@ public class Window extends Container implements Accessible
*/
public synchronized void addWindowListener(WindowListener listener)
{
- windowListener = AWTEventMulticaster.add(windowListener, listener);
+ if (listener != null)
+ {
+ newEventsOnly = true;
+ windowListener = AWTEventMulticaster.add(windowListener, listener);
+ }
}
/**
@@ -555,7 +559,12 @@ public class Window extends Container implements Accessible
*/
public void addWindowFocusListener (WindowFocusListener wfl)
{
- windowFocusListener = AWTEventMulticaster.add (windowFocusListener, wfl);
+ if (wfl != null)
+ {
+ newEventsOnly = true;
+ windowFocusListener = AWTEventMulticaster.add (windowFocusListener,
+ wfl);
+ }
}
/**
@@ -565,7 +574,12 @@ public class Window extends Container implements Accessible
*/
public void addWindowStateListener (WindowStateListener wsl)
{
- windowStateListener = AWTEventMulticaster.add (windowStateListener, wsl);
+ if (wsl != null)
+ {
+ newEventsOnly = true;
+ windowStateListener = AWTEventMulticaster.add (windowStateListener,
+ wsl);
+ }
}
/**
@@ -624,7 +638,28 @@ public class Window extends Container implements Accessible
protected void processEvent(AWTEvent evt)
{
if (evt instanceof WindowEvent)
- processWindowEvent((WindowEvent) evt);
+ {
+ WindowEvent we = (WindowEvent) evt;
+ switch (evt.getID())
+ {
+ case WindowEvent.WINDOW_OPENED:
+ case WindowEvent.WINDOW_CLOSED:
+ case WindowEvent.WINDOW_CLOSING:
+ case WindowEvent.WINDOW_ICONIFIED:
+ case WindowEvent.WINDOW_DEICONIFIED:
+ case WindowEvent.WINDOW_ACTIVATED:
+ case WindowEvent.WINDOW_DEACTIVATED:
+ processWindowEvent(we);
+ break;
+ case WindowEvent.WINDOW_GAINED_FOCUS:
+ case WindowEvent.WINDOW_LOST_FOCUS:
+ processWindowFocusEvent(we);
+ break;
+ case WindowEvent.WINDOW_STATE_CHANGED:
+ processWindowStateEvent(we);
+ break;
+ }
+ }
else
super.processEvent(evt);
}
@@ -639,54 +674,35 @@ public class Window extends Container implements Accessible
*/
protected void processWindowEvent(WindowEvent evt)
{
- int id = evt.getID();
-
- if (id == WindowEvent.WINDOW_GAINED_FOCUS
- || id == WindowEvent.WINDOW_LOST_FOCUS)
- processWindowFocusEvent (evt);
- else if (id == WindowEvent.WINDOW_STATE_CHANGED)
- processWindowStateEvent (evt);
- else
+ if (windowListener != null)
{
- if (windowListener != null)
- {
- switch (evt.getID())
- {
- case WindowEvent.WINDOW_ACTIVATED:
- windowListener.windowActivated(evt);
- break;
-
- case WindowEvent.WINDOW_CLOSED:
- windowListener.windowClosed(evt);
- break;
-
- case WindowEvent.WINDOW_CLOSING:
- windowListener.windowClosing(evt);
- break;
-
- case WindowEvent.WINDOW_DEACTIVATED:
- windowListener.windowDeactivated(evt);
- break;
-
- case WindowEvent.WINDOW_DEICONIFIED:
- windowListener.windowDeiconified(evt);
- break;
-
- case WindowEvent.WINDOW_ICONIFIED:
- windowListener.windowIconified(evt);
- break;
-
- case WindowEvent.WINDOW_OPENED:
- windowListener.windowOpened(evt);
- break;
-
- default:
- break;
- }
- }
+ switch (evt.getID())
+ {
+ case WindowEvent.WINDOW_ACTIVATED:
+ windowListener.windowActivated(evt);
+ break;
+ case WindowEvent.WINDOW_CLOSED:
+ windowListener.windowClosed(evt);
+ break;
+ case WindowEvent.WINDOW_CLOSING:
+ windowListener.windowClosing(evt);
+ break;
+ case WindowEvent.WINDOW_DEACTIVATED:
+ windowListener.windowDeactivated(evt);
+ break;
+ case WindowEvent.WINDOW_DEICONIFIED:
+ windowListener.windowDeiconified(evt);
+ break;
+ case WindowEvent.WINDOW_ICONIFIED:
+ windowListener.windowIconified(evt);
+ break;
+ case WindowEvent.WINDOW_OPENED:
+ windowListener.windowOpened(evt);
+ break;
+ }
}
}
-
+
/**
* Identifies if this window is active. The active window is a Frame or
* Dialog that has focus or owns the active window.
@@ -1231,6 +1247,42 @@ public class Window extends Container implements Accessible
return "win" + getUniqueLong();
}
+ /**
+ * Overridden to handle WindowEvents.
+ *
+ * @return <code>true</code> when the specified event type is enabled,
+ * <code>false</code> otherwise
+ */
+ boolean eventTypeEnabled(int type)
+ {
+ boolean enabled = false;
+ switch (type)
+ {
+ case WindowEvent.WINDOW_OPENED:
+ case WindowEvent.WINDOW_CLOSED:
+ case WindowEvent.WINDOW_CLOSING:
+ case WindowEvent.WINDOW_ICONIFIED:
+ case WindowEvent.WINDOW_DEICONIFIED:
+ case WindowEvent.WINDOW_ACTIVATED:
+ case WindowEvent.WINDOW_DEACTIVATED:
+ enabled = ((eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0)
+ || windowListener != null;
+ break;
+ case WindowEvent.WINDOW_GAINED_FOCUS:
+ case WindowEvent.WINDOW_LOST_FOCUS:
+ enabled = ((eventMask & AWTEvent.WINDOW_FOCUS_EVENT_MASK) != 0)
+ || windowFocusListener != null;
+ break;
+ case WindowEvent.WINDOW_STATE_CHANGED:
+ enabled = ((eventMask & AWTEvent.WINDOW_STATE_EVENT_MASK) != 0)
+ || windowStateListener != null;
+ break;
+ default:
+ enabled = super.eventTypeEnabled(type);
+ }
+ return enabled;
+ }
+
private static synchronized long getUniqueLong()
{
return next_window_number++;