1 |
/* Copyright (C) 1999, 2000, 2002 Free Software Foundation |
/* Window.java -- |
2 |
|
Copyright (C) 1999, 2000, 2002 Free Software Foundation |
|
Copyright (C) 1999 Free Software Foundation, Inc. |
|
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
35 |
obligated to do so. If you do not wish to do so, delete this |
obligated to do so. If you do not wish to do so, delete this |
36 |
exception statement from your version. */ |
exception statement from your version. */ |
37 |
|
|
38 |
|
|
39 |
package java.awt; |
package java.awt; |
40 |
|
|
41 |
import java.awt.event.WindowEvent; |
import java.awt.event.WindowEvent; |
42 |
import java.awt.event.WindowListener; |
import java.awt.event.WindowListener; |
43 |
import java.awt.peer.WindowPeer; |
import java.awt.peer.WindowPeer; |
146 |
public void addNotify() |
public void addNotify() |
147 |
{ |
{ |
148 |
if (peer == null) |
if (peer == null) |
149 |
peer = getToolkit ().createWindow (this); |
peer = getToolkit().createWindow(this); |
150 |
super.addNotify (); |
super.addNotify(); |
151 |
} |
} |
152 |
|
|
153 |
/** |
/** |
172 |
/** |
/** |
173 |
* Makes this window visible and brings it to the front. |
* Makes this window visible and brings it to the front. |
174 |
*/ |
*/ |
175 |
public void show () |
public void show() |
176 |
{ |
{ |
177 |
if (peer == null) |
if (peer == null) |
178 |
addNotify(); |
addNotify(); |
207 |
* Sends this window to the back so that all other windows display in |
* Sends this window to the back so that all other windows display in |
208 |
* front of it. |
* front of it. |
209 |
*/ |
*/ |
210 |
public void toBack () |
public void toBack() |
211 |
{ |
{ |
212 |
if (peer != null) |
if (peer != null) |
213 |
{ |
{ |
214 |
WindowPeer wp = (WindowPeer) peer; |
WindowPeer wp = (WindowPeer) peer; |
215 |
wp.toBack (); |
wp.toBack(); |
216 |
} |
} |
217 |
} |
} |
218 |
|
|
220 |
* Brings this window to the front so that it displays in front of |
* Brings this window to the front so that it displays in front of |
221 |
* any other windows. |
* any other windows. |
222 |
*/ |
*/ |
223 |
public void toFront () |
public void toFront() |
224 |
{ |
{ |
225 |
if (peer != null) |
if (peer != null) |
226 |
{ |
{ |
227 |
WindowPeer wp = (WindowPeer) peer; |
WindowPeer wp = (WindowPeer) peer; |
228 |
wp.toFront (); |
wp.toFront(); |
229 |
} |
} |
230 |
} |
} |
231 |
|
|
239 |
*/ |
*/ |
240 |
public Toolkit getToolkit() |
public Toolkit getToolkit() |
241 |
{ |
{ |
242 |
return Toolkit.getDefaultToolkit (); |
return Toolkit.getDefaultToolkit(); |
243 |
} |
} |
244 |
|
|
245 |
/** |
/** |
271 |
* |
* |
272 |
* @return The locale this window is configured for. |
* @return The locale this window is configured for. |
273 |
*/ |
*/ |
274 |
public Locale getLocale () |
public Locale getLocale() |
275 |
{ |
{ |
276 |
return locale == null ? Locale.getDefault () : locale; |
return locale == null ? Locale.getDefault() : locale; |
277 |
} |
} |
278 |
|
|
279 |
/* |
/* |
313 |
* |
* |
314 |
* @param listener The <code>WindowListener</code> to add. |
* @param listener The <code>WindowListener</code> to add. |
315 |
*/ |
*/ |
316 |
public synchronized void addWindowListener (WindowListener listener) |
public synchronized void addWindowListener(WindowListener listener) |
317 |
{ |
{ |
318 |
windowListener = AWTEventMulticaster.add (windowListener, listener); |
windowListener = AWTEventMulticaster.add(windowListener, listener); |
319 |
} |
} |
320 |
|
|
321 |
/** |
/** |
324 |
* |
* |
325 |
* @param listener The <code>WindowListener</code> to remove. |
* @param listener The <code>WindowListener</code> to remove. |
326 |
*/ |
*/ |
327 |
public synchronized void removeWindowListener (WindowListener listener) |
public synchronized void removeWindowListener(WindowListener listener) |
328 |
{ |
{ |
329 |
windowListener = AWTEventMulticaster.remove (windowListener, listener); |
windowListener = AWTEventMulticaster.remove(windowListener, listener); |
330 |
} |
} |
331 |
|
|
332 |
public synchronized WindowListener[] getWindowListeners() |
public synchronized WindowListener[] getWindowListeners() |
364 |
* |
* |
365 |
* @param event The event to process. |
* @param event The event to process. |
366 |
*/ |
*/ |
367 |
protected void processEvent (AWTEvent evt) |
protected void processEvent(AWTEvent evt) |
368 |
{ |
{ |
369 |
if (evt instanceof WindowEvent) |
if (evt instanceof WindowEvent) |
370 |
processWindowEvent ((WindowEvent) evt); |
processWindowEvent((WindowEvent) evt); |
371 |
else |
else |
372 |
super.processEvent (evt); |
super.processEvent(evt); |
373 |
} |
} |
374 |
|
|
375 |
/** |
/** |
380 |
* |
* |
381 |
* @param event The event to process. |
* @param event The event to process. |
382 |
*/ |
*/ |
383 |
protected void processWindowEvent (WindowEvent evt) |
protected void processWindowEvent(WindowEvent evt) |
384 |
{ |
{ |
385 |
if (windowListener != null) |
if (windowListener != null) |
386 |
{ |
{ |
387 |
switch (evt.getID ()) |
switch (evt.getID()) |
388 |
{ |
{ |
389 |
case WindowEvent.WINDOW_ACTIVATED: |
case WindowEvent.WINDOW_ACTIVATED: |
390 |
windowListener.windowActivated (evt); |
windowListener.windowActivated(evt); |
391 |
break; |
break; |
392 |
case WindowEvent.WINDOW_CLOSED: |
case WindowEvent.WINDOW_CLOSED: |
393 |
windowListener.windowClosed (evt); |
windowListener.windowClosed(evt); |
394 |
break; |
break; |
395 |
case WindowEvent.WINDOW_CLOSING: |
case WindowEvent.WINDOW_CLOSING: |
396 |
windowListener.windowClosing (evt); |
windowListener.windowClosing(evt); |
397 |
break; |
break; |
398 |
case WindowEvent.WINDOW_DEACTIVATED: |
case WindowEvent.WINDOW_DEACTIVATED: |
399 |
windowListener.windowDeactivated (evt); |
windowListener.windowDeactivated(evt); |
400 |
break; |
break; |
401 |
case WindowEvent.WINDOW_DEICONIFIED: |
case WindowEvent.WINDOW_DEICONIFIED: |
402 |
windowListener.windowDeiconified (evt); |
windowListener.windowDeiconified(evt); |
403 |
break; |
break; |
404 |
case WindowEvent.WINDOW_ICONIFIED: |
case WindowEvent.WINDOW_ICONIFIED: |
405 |
windowListener.windowIconified (evt); |
windowListener.windowIconified(evt); |
406 |
break; |
break; |
407 |
case WindowEvent.WINDOW_OPENED: |
case WindowEvent.WINDOW_OPENED: |
408 |
windowListener.windowOpened (evt); |
windowListener.windowOpened(evt); |
409 |
break; |
break; |
410 |
} |
} |
411 |
} |
} |