KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > dwipal > DwEvtQueue


1 package com.dwipal;
2
3 import java.awt.*;
4 /** This class implements the "DoEvents" function, which allows
5  * the event queue to perform its events.
6  */

7    
8 public class DwEvtQueue extends java.awt.EventQueue JavaDoc {
9     
10 /** Create a new instance of the class
11  */

12 public DwEvtQueue() {
13 }
14
15 /** execute the event queue
16  */

17 public void doEvents()
18 {
19 Toolkit toolKit = Toolkit.getDefaultToolkit();
20 EventQueue evtQueue = toolKit.getSystemEventQueue();
21
22 // loop whilst there are events to process
23
while (evtQueue.peekEvent() != null)
24 {
25 try
26 {
27 // if there are then get the event
28
AWTEvent evt = evtQueue.getNextEvent();
29 // and dispatch it
30
super.dispatchEvent(evt);
31 }
32 catch (java.lang.InterruptedException JavaDoc e)
33 {
34 // if we get an exception in getNextEvent()
35
// do nothing
36
;
37 }
38 }
39 }
40 }
41
42
Popular Tags