Class LoadingIcon

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.util.EventListener, javax.swing.Icon
    Direct Known Subclasses:
    LoadingIcon.Unsafe

    public class LoadingIcon
    extends java.lang.Object
    implements javax.swing.Icon, java.awt.event.ActionListener
    An icon that displays an simple animation while something is loading
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  LoadingIcon.Unsafe
      This class is a subclass of LoadingIcon that uses a (shared) java.util.Timer, and issues repaintImmediately commands to the parent component on non-EDT thread.
    • Constructor Summary

      Constructors 
      Constructor Description
      LoadingIcon()
      Creates a new loading icon with a default delay of 50ms between frames (initially stopped)
      LoadingIcon​(int delay)
      Creates a new loading icon (initially stopped)
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void actionPerformed​(java.awt.event.ActionEvent e)  
      int getIconHeight()  
      int getIconWidth()  
      protected void initTimer​(int delay)  
      void paintIcon​(java.awt.Component c, java.awt.Graphics graphics, int x, int y)  
      protected void repaintParent()  
      void start()
      Start the animation
      void stop()
      Stop the animation
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LoadingIcon

        public LoadingIcon()
        Creates a new loading icon with a default delay of 50ms between frames (initially stopped)
      • LoadingIcon

        public LoadingIcon​(int delay)
        Creates a new loading icon (initially stopped)
        Parameters:
        delay - The delay between animation frames
    • Method Detail

      • initTimer

        protected void initTimer​(int delay)
      • getIconHeight

        public int getIconHeight()
        Specified by:
        getIconHeight in interface javax.swing.Icon
      • getIconWidth

        public int getIconWidth()
        Specified by:
        getIconWidth in interface javax.swing.Icon
      • start

        public void start()
        Start the animation
      • stop

        public void stop()
        Stop the animation
      • paintIcon

        public void paintIcon​(java.awt.Component c,
                              java.awt.Graphics graphics,
                              int x,
                              int y)
        Specified by:
        paintIcon in interface javax.swing.Icon
      • actionPerformed

        public void actionPerformed​(java.awt.event.ActionEvent e)
        Specified by:
        actionPerformed in interface java.awt.event.ActionListener
      • repaintParent

        protected void repaintParent()