title: Exception thrown in SwingWorker
body: <p>I am trying to use a <code>SwingWorker</code> in the <code>importData(..)</code> method from the <code>TransferHandler</code> class (to support drag and drop). I want to show the import progress of the files that I dragged. However, it does not work. I don't understand what the problem is, or what causing it.</p>
  
  <pre><code>private class FileImportTransferHandler extends TransferHandler {
  
      @Override
      public boolean importData(JComponent comp, final Transferable t) {
  
          SwingWorker&lt;Void, String&gt; worker = new SwingWorker&lt;Void, String&gt;() {
  
              @Override
              protected Void doInBackground() throws Exception {
                  //When commenting this code it and everything else it doesn't
                  DataFlavor[] flavors = t.getTransferDataFlavors(); //&lt;---- throws exception 
                  //..more code that doesn't run.
              }
  
              @Override
              protected void done() {
                  super.done();
  
                  try {
                      get();
                  } catch (InterruptedException ex) {
                      Logger.getLogger(ImportBeanController.class.getName()).log(Level.SEVERE, null, ex);
                  } catch (ExecutionException ex) {
                      Logger.getLogger(ImportBeanController.class.getName()).log(Level.SEVERE, null, ex);
                  }
              }
          }
         //Starting worker etc here.
      }       
  }
  </code></pre>
  
  <p>Exception:</p>
  
  <blockquote>
    <p>java.util.concurrent.ExecutionException:
    java.lang.NullPointerException    at
    java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222)    at
    java.util.concurrent.FutureTask.get(FutureTask.java:83)   at
    javax.swing.SwingWorker.get(SwingWorker.java:582)     at
    com.jatech.app.controllers$ImportBeanController$1.done(ImportBeanController.java:158)
      at javax.swing.SwingWorker$5.run(SwingWorker.java:717)  at
    javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.run(SwingWorker.java:814)
      at sun.swing.AccumulativeRunnable.run(AccumulativeRunnable.java:95)
      at
    javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.actionPerformed(SwingWorker.java:824)
      at javax.swing.Timer.fireActionPerformed(Timer.java:291)    at
    javax.swing.Timer$DoPostEvent.run(Timer.java:221)     at
    java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)     at
    java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)    at
    java.awt.EventQueue.access$000(EventQueue.java:84)    at
    java.awt.EventQueue$1.run(EventQueue.java:602)    at
    java.awt.EventQueue$1.run(EventQueue.java:600)    at
    java.security.AccessController.doPrivileged(Native Method)    at
    java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)   at
    java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
      at
    java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
      at
    java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
      at
    java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
      at
    java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    Caused by: java.lang.NullPointerException     at
    sun.awt.dnd.SunDropTargetContextPeer.getTransferDataFlavors(SunDropTargetContextPeer.java:176)
      at
    sun.awt.datatransfer.TransferableProxy.getTransferDataFlavors(TransferableProxy.java:48)
      at
    java.awt.dnd.DropTargetContext$TransferableProxy.getTransferDataFlavors(DropTargetContext.java:327)</p>
  </blockquote>