Question

I want to run a certain function from doInBackground on the EDT. I have it currently setup using publish and process which is working just fine. However, I want to know if there is a way to have a function run on the EDT from doInBackground without using publish and process. Also, without using invokeLater. Can I do this somehow?

Was it helpful?

Solution

You would do this as you would queue any code onto the EDT: via a Runnable that is added to the event queue:

   protected void doInBackground() throws Exception {

      // code to be called off of the EDT

      SwingUtilities.invokeLater(new Runnable() {
         public void run() {

            // code to be called on the EDT

         }
      });
      return null;
   }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top