/** * Creates a proxy version of <tt>interfaceClass</tt> that executes <tt>instance</tt> * on the Swing EDT when any of its methods are invoked. * * @param interfaceClass the interface to generate. * @param instance the instance to delegate calls to. * @return a new instance of <tt>interfaceclass</tt>. */ public <T> T wrap(Class<T> interfaceClass, T instance) { return interfaceClass.cast(Proxy.newProxyInstance(interfaceClass.getClassLoader(), new Class[]{ interfaceClass }, new ExecutorInvocationProxy(instance, this))); }