Class CircularLoader

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Animatable

public class CircularLoader extends JPanel implements Animatable
A circular progressbar commonly used in web based AJAX applications. The look of this component has become popular, and although it is available by default on macOS this class provides a generic implementation. The component can be rescaled to any size using JComponent.setPreferredSize(Dimension).
See Also:
  • Constructor Details

    • CircularLoader

      public CircularLoader(int size)
      Creates a new CircularLoader of the specified size. If a size of 0 is specified the size at which the component will be displayed is determined by the layout manager that owns it.
      Parameters:
      size - The component size in pixels.
  • Method Details

    • paintComponent

      protected void paintComponent(Graphics g)
      Overrides:
      paintComponent in class JComponent
    • onFrame

      public void onFrame(float deltaTime)
      Description copied from interface: Animatable
      Called every frame update while the animation is active.
      Specified by:
      onFrame in interface Animatable
      Parameters:
      deltaTime - Time since the last frame update, in seconds.
    • setLineColor

      public void setLineColor(Color lineColor)
    • getLineColor

      public Color getLineColor()
    • setLineStroke

      public void setLineStroke(Stroke lineStroke)
    • setLineStroke

      public void setLineStroke(float strokeWidth)
    • getLineStroke

      public Stroke getLineStroke()
    • createAnimation

      public static BufferedImage[] createAnimation(int size, Color lineColor, Stroke lineStroke)
      Returns an array of frame images. When the animation starts all frames are painted in advance, so that the rest of the animation just requires painting the images instead of having to repaint the animation itself.

      This method is static so that non-Swing applications can use the graphics used by this component.

      Parameters:
      size - The width/height of the created images.
      Returns:
      An array of all frames, its length depends on the number of frames.