- Inherits from:
- NSView : NSResponder : NSObject
- Package:
- com.apple.yellow.application
An application displays a progress indicator to show that a lengthy task is under way. Some progress indicators do nothing more than spin to show that the application is busy, while others show the percentage of the task that has been completed. NSProgressIndicator provides both types of display:
NSProgressIndicator is a subclass of NSView. To display a progress indicator, your application creates a window and adds the progress indicator as a subview of the window's content view or any subview. You can create a progress indicator programmatically with its constructor. However, you normally use Interface Builder to create and initialize a progress indicator and to install it in an application view.
For an indeterminate progress indicator, you invoke startAnimation to start the animation (the spinning of the barber pole) and stopAnimation when the task is complete. By default, the delay between animation steps is one twelfth of a second (5.0/60.0). You can change the animation delay by invoking setAnimationDelay. Setting the delay to a double value larger than the default value will slow the animation, while setting the delay to a smaller value will speed it up.
Instead of invoking startAnimation and stopAnimation, you can control an indeterminate progress indicator directly by sending the animate message. Each time you invoke animate, the animation advances by one step. You can speed up or slow down the animation by varying how often you invoke animate. Like other views, a progress indicator redisplays itself on each pass through the event loop, if needed. To ensure immediate redrawing, however, you can invoke the displayIfNeeded method (inherited from NSView) each time you invoke animate.
By default, a progress indicator is indeterminate. Your can specify a determinate progress indicator when you set up the view with Interface Builder, or you can use code like the following to change the default value programmatically:
[myProgressIndicatorView.setIndeterminate(true)];
For a determinate progress indicator, you invoke the incrementBy method to advance the progress bar. By default, a determinate progress indicator goes from 0.0 to 100.0. You can increment by any amount, but if you vary the increment too widely, progress may appear uneven or jerky. You typically choose an increment value that evenly divides 100.0. For example, you might invoke incrementBy 50 times, incrementing by 2.0 each time, to draw the complete progress bar. To modify the default range of 0.0 to 100.0, you can invoke setMinValue to modify the minimum value and setMaxValue to modify the maximum value.
After each invocation of incrementBy, you can invoke the displayIfNeeded method to ensure immediate redrawing.
You can display progress indicators of different sizes by varying the frame size. However, the default size is designed to provide the best results. By default, a progress indicator is drawn with a bezeled frame, but you can use the setBezeled method to modify the bezeled-frame setting.
A progress indicator is drawn with colors based on the user's current color scheme. When the user changes the color scheme, the color of the progress indicator changes automatically to match the new scheme.
- Constructors
- NSProgressIndicator
- Animating the progress indicator
- animate
- animationDelay
- setAnimationDelay
- setUsesThreadedAnimation
- startAnimation
- stopAnimation
- usesThreadedAnimation
- Advancing the progress bar
- incrementBy
- setDoubleValue
- doubleValue
- setMinValue
- minValue
- setMaxValue
- maxValue
- Setting the appearance
- setBezeled
- isBezeled
- setIndeterminate
- isIndeterminate
public NSProgressIndicator()
public NSProgressIndicator(NSRect frameRect)
It's usually more convenient to use Interface Builder, which allows you to create an NSProgressIndicator and embed it in the superview of your choice.
public void animate(Object sender)
The animate method only invalidates the progress indicator so it will be redrawn the next time through the event loop. To ensure immediate redrawing, invoke the displayIfNeeded method.
See Also: animationDelay, setAnimationDelay
public double animationDelay()
See Also: animate
public double doubleValue()
See Also: incrementBy, setDoubleValue
public void incrementBy(double delta)
See Also: doubleValue
public boolean isBezeled()
true
if
the receiver's frame has a three-dimensional bezel.See Also: setBezeled
public boolean isIndeterminate()
true
if
the receiver is indeterminate. An indeterminate
progress indicator displays a "barber pole" that spins until
the task is complete. A determinate progress indicator draws a three-dimensional
bar from left to right as the task progresses.See Also: setIndeterminate
public double maxValue()
See Also: minValue, setMaxValue
public double minValue()
See Also: maxValue, setMinValue
public void setAnimationDelay(double delay)
public void setBezeled(boolean flag)
See Also: isBezeled
public void setDoubleValue(double doubleValue)
See Also: doubleValue, incrementBy, setMaxValue, setMinValue
public void setIndeterminate(boolean flag)
See Also: isIndeterminate
public void setMaxValue(double newMaximum)
See Also: maxValue
public void setMinValue(double newMinimum)
See Also: minValue
public void setUsesThreadedAnimation(boolean flag)
See Also: usesThreadedAnimation
public void startAnimation(Object sender)
See Also: animationDelay, stopAnimation
public void stopAnimation(Object sender)
See Also: animationDelay, startAnimation
public boolean usesThreadedAnimation()
See Also: setUsesThreadedAnimation