Class JXBusyLabel

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

    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:
    Serialized Form
    • Constructor Detail

      • 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 Detail

      • setDirection

        public void setDirection​(JXBusyLabel.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:
        getBusyPainter(), setBusyPainter(BusyPainter)
      • 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.
        See Also:
        JLabel.getUI()
      • 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
      • frameChanged

        protected void frameChanged()
      • 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 L&F has changed. Replaces the current UI object with the latest version from the UIManager.
        Overrides:
        updateUI in class JLabel
        See Also:
        JComponent.updateUI()