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