jdk/test/java/awt/regtesthelpers/Util.java
changeset 12535 6d2ee83614e8
parent 5506 202f599c92aa
child 12829 506020af237a
equal deleted inserted replaced
12534:5fbdf283ed28 12535:6d2ee83614e8
   598                                     }
   598                                     }
   599                                 },
   599                                 },
   600                                 time, printEvent);
   600                                 time, printEvent);
   601 
   601 
   602     }
   602     }
       
   603 
       
   604 
       
   605     /**
       
   606      * Invokes the <code>task</code> on the EDT thread.
       
   607      *
       
   608      * @return result of the <code>task</code>
       
   609      */
       
   610     public static <T> T invokeOnEDT(final java.util.concurrent.Callable<T> task) throws Exception {
       
   611         final java.util.List<T> result = new java.util.ArrayList<T>(1);
       
   612         final Exception[] exception = new Exception[1];
       
   613 
       
   614         javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
       
   615 
       
   616             @Override
       
   617             public void run() {
       
   618                 try {
       
   619                     result.add(task.call());
       
   620                 } catch (Exception e) {
       
   621                     exception[0] = e;
       
   622                 }
       
   623             }
       
   624         });
       
   625 
       
   626         if (exception[0] != null) {
       
   627             throw exception[0];
       
   628         }
       
   629 
       
   630         return result.get(0);
       
   631     }
       
   632 
   603 }
   633 }