Class BlinkerSwingWorker

java.lang.Object
javax.swing.SwingWorker<Void,Void>
com.j3d.threads.BlinkerSwingWorker
All Implemented Interfaces:
Runnable, Future<Void>, RunnableFuture<Void>

public class BlinkerSwingWorker extends SwingWorker<Void,Void>
A SwingWorker implementation designed to perform a blinking effect on a UI component. It repeatedly executes a given Runnable, repainting the main panel, with a specified delay between repetitions. After the blinking sequence completes, it removes an overlap identified by a UUID from the scene manager.
Author:
Lehlogonolo Poole
See Also:
  • Field Details

    • waitMs

      private final long waitMs
    • repeatAmtTimes

      private final int repeatAmtTimes
    • runnable

      private final Runnable runnable
    • idToRemove

      private final UUID idToRemove
  • Constructor Details

    • BlinkerSwingWorker

      public BlinkerSwingWorker(long waitMs, int repeatAmtTimes, Runnable set, UUID uuid)
      Constructs a new BlinkerSwingWorker.
      Parameters:
      waitMs - The delay in milliseconds between each blink cycle (repaint, run, repaint).
      repeatAmtTimes - The number of times the blink cycle should be repeated.
      set - The Runnable to be executed during each blink cycle. This typically toggles the visibility or state of the element to be blinked.
      uuid - The UUID of the overlap to be removed from the scene manager once the blinking sequence is complete.
  • Method Details

    • repeat

      private void repeat()
      Executes the blinking sequence. It loops `repeatAmtTimes` times, performing the following steps in each iteration:
      1. Sleeps for waitMs milliseconds.
      2. Executes the provided runnable.
      3. Repaints the StaticRefs.getMainPanel().
      If the thread is interrupted during sleep, the exception is caught and ignored.
    • doInBackground

      protected Void doInBackground() throws Exception
      The main task to be executed in the background by this SwingWorker. It first calls the repeat() method to perform the blinking, and then removes the specified overlap from the scene manager.
      Specified by:
      doInBackground in class SwingWorker<Void,Void>
      Returns:
      null as this worker does not produce any intermediate results or a final result.
      Throws:
      Exception