Class JXBusyLabel

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

@JavaBean public class JXBusyLabel extends JLabel

A simple circular animation, useful for denoting an action is taking place that may take an unknown length of time to complete. Similar to an indeterminant JProgressBar, but with a different look.

For example:


     JXFrame frame = new JXFrame("test", true);
     JXBusyLabel label = new JXBusyLabel();
     frame.add(label);
     //...
     label.setBusy(true);
 
Another more complicated example:

 JXBusyLabel label = new JXBusyLabel(new Dimension(100,84));
 BusyPainter painter = new BusyPainter(
 new Rectangle2D.Float(0, 0,13.500001f,1),
 new RoundRectangle2D.Float(12.5f,12.5f,59.0f,59.0f,10,10));
 painter.setTrailLength(5);
 painter.setPoints(31);
 painter.setFrame(1);
 label.setPreferredSize(new Dimension(100,84));
 label.setIcon(new EmptyIcon(100,84));
 label.setBusyPainter(painter);
Another example:

     JXBusyLabel label = new MyBusyLabel(new Dimension(100, 84));
 
where MyBusyLabel is:

 public class MyBusyLabel extends JXBusyLabel {
     public MyBusyLabel(Dimension prefSize) {
         super(prefSize);
     }
     
     protected BusyLabel createBusyLabel(Dimension dim) {
         BusyPainter painter = new BusyPainter(
         new Rectangle2D.Float(0, 0,13.500001f,1),
         new RoundRectangle2D.Float(12.5f,12.5f,59.0f,59.0f,10,10));
         painter.setTrailLength(5);
         painter.setPoints(31);
         painter.setFrame(1);
         
         return painter;
     }
 }
 
Author:
rbair, joshy, rah003, headw01
See Also:
  • Field Details

  • Constructor Details

    • JXBusyLabel

      public JXBusyLabel()
      Creates a new instance of JXBusyLabel initialized to circular shape in bounds of 26 by 26 points.
    • JXBusyLabel

      public JXBusyLabel(Dimension dim)
      Creates a new instance of JXBusyLabel initialized to the arbitrary size and using default circular progress indicator.
      Parameters:
      dim - Preferred size of the label.
  • Method Details

    • setDirection

      public void setDirection(BusyPainter.Direction dir)
      Sets direction of rotation. Direction.RIGHT is the default value. Direction is taken from the very top point so Direction.RIGHT enables rotation clockwise.
      Parameters:
      dir - Direction of rotation.
    • initPainter

      protected void initPainter(Dimension dim)
      Initialize the BusyPainter and (this) JXBusyLabel with the given preferred size. This method is called automatically when the BusyPainter is set/changed.
      Parameters:
      dim - The new Preferred Size for the BusyLabel.
      See Also:
    • createBusyPainter

      protected BusyPainter createBusyPainter(Dimension dim)
      Create and return a BusyPpainter to use for the Label. This may be overridden to return any painter you like. By default, this method uses the UI (BusyLabelUI) to create a BusyPainter.
      Parameters:
      dim - Painter size.
      Returns:
      BusyPainter
      See Also:
    • isBusy

      public boolean isBusy()

      Gets whether this JXBusyLabel is busy. If busy, then the JXBusyLabel instance will indicate that it is busy, generally by animating some state.

      Returns:
      true if this instance is busy
    • setBusy

      public void setBusy(boolean busy)

      Sets whether this JXBusyLabel instance should consider itself busy. A busy component may indicate that it is busy via animation, or some other means.

      Parameters:
      busy - whether this JXBusyLabel instance should consider itself busy
    • removeNotify

      public void removeNotify()
      Overrides:
      removeNotify in class JComponent
    • addNotify

      public void addNotify()
      Overrides:
      addNotify in class JComponent
    • frameChanged

      protected void frameChanged()
      repaint
    • getBusyPainter

      public final BusyPainter getBusyPainter()
      Returns the current BusyPainter. If no BusyPainter is currently set on this BusyLabel, the createBusyPainter(Dimension) method is called to create one. Afterwards, initPainter(Dimension) is called to update the BusyLabel with the created BusyPainter.
      Returns:
      the busyPainter
      See Also:
    • setBusyPainter

      public final void setBusyPainter(BusyPainter busyPainter)
      Parameters:
      busyPainter - the busyPainter to set
    • getDelay

      public int getDelay()
      Returns:
      the delay
    • setDelay

      public void setDelay(int delay)
      Parameters:
      delay - the delay to set
    • updateUI

      public void updateUI()
      Notification from the UIManager that the LaF has changed. Replaces the current UI object with the latest version from the UIManager.
      Overrides:
      updateUI in class JLabel
      See Also:
    • getUIClassID

      public String getUIClassID()
      Returns the name of the LaF class that renders this component.
      Overrides:
      getUIClassID in class JLabel
      Returns:
      the string uiClassID
      See Also: