Class IrisSwingUtilities

java.lang.Object
com.illumon.iris.gui.util.IrisSwingUtilities

public class IrisSwingUtilities
extends Object
Utility class for swing related methods.
  • Constructor Details

  • Method Details

    • setTestMode

      @TestUseOnly public static void setTestMode()
    • isEventDispatchThreadOrTestMode

      public static boolean isEventDispatchThreadOrTestMode()
    • invokeOnEventThread

      public static void invokeOnEventThread​(Runnable doRun)
      Run immediately if this is the Event Thread, else invokeLater().
      Parameters:
      doRun - the stuff to do
    • invokeAndWaitOnEventThread

      public static void invokeAndWaitOnEventThread​(Runnable doRun) throws InvocationTargetException, InterruptedException
      Run immediately if this is the Event Thread, else invokeLater() or invokeAndWait() if synchronous is true.
      Parameters:
      doRun - the stuff to do
      Throws:
      InvocationTargetException
      InterruptedException
    • invokeOffEventThread

      public static void invokeOffEventThread​(Runnable doRun)
      Run immediately if this is not the Event Thread, else run on a dedicated single-purpose thread
      Parameters:
      doRun - the stuff to do
    • invokeOffEventThread

      public static void invokeOffEventThread​(Runnable doRun, ExecutorService pool)
      Run immediately if this is not the Event Thread, else run on the supplied thread pool
      Parameters:
      doRun - the stuff to do
      pool - a supplied thread pool where the stuff may be run
    • adjustFocus

      public static void adjustFocus​(JComponent c)
      Ensure that the passed-in component is the focused item.
      Parameters:
      c - the component to focus
    • shouldIgnore

      public static boolean shouldIgnore​(MouseEvent event, JComponent c)
      Check if an event should be ignored by a handler. That is, if the component is enabled, or the event has already been consumed.
      Parameters:
      event - the event
      c - the component
      Returns:
      true if the event should be ignored, false otherwise