1 8 9 package foxtrot.pumps; 10 11 import java.awt.AWTEvent ; 12 import java.lang.reflect.Field ; 13 import java.security.AccessController ; 14 import java.security.PrivilegedExceptionAction ; 15 import java.util.LinkedList ; 16 17 24 public class SunJDK140ConditionalEventPump extends SunJDK14ConditionalEventPump 25 { 26 private static Class sequencedEventClass; 27 private static Field listField; 28 29 static 30 { 31 try 32 { 33 AccessController.doPrivileged(new PrivilegedExceptionAction () 34 { 35 public Object run() throws Exception 36 { 37 ClassLoader loader = ClassLoader.getSystemClassLoader(); 38 sequencedEventClass = loader.loadClass("java.awt.SequencedEvent"); 39 listField = sequencedEventClass.getDeclaredField("list"); 40 listField.setAccessible(true); 41 return null; 42 } 43 }); 44 } 45 catch (Throwable x) 46 { 47 if (debug) x.printStackTrace(); 48 throw new Error (x.toString()); 49 } 50 } 51 52 protected boolean canPumpEvent(AWTEvent event) 53 { 54 try 55 { 56 LinkedList list = (LinkedList )listField.get(event); 57 synchronized (sequencedEventClass) 58 { 59 if (list.getFirst() == event) return true; 60 } 61 } 62 catch (Exception x) 63 { 64 } 65 return false; 66 } 67 } 68 | Popular Tags |