Class AMDProgressBarEmbed
java.lang.Object
|
+----AMDProgressBarEmbed
- public class AMDProgressBarEmbed
- extends Object
A ProgressBar bar is a widget which indicates how close a task is to
completion. The developer can create a ProgressBar bar, draw it
somewhere on screen, and make the bar move from 0% to 100% while
the rest of the program does something time consuming.
There are two versions of the ProgressBar bar, one which is a subclass
of an AWT component, and one which can be embedded in the drawing
area of other components. AMDProgressBarEmbed must be embedded in the
drawing area of another component to work, usually an Applet or
Canvas. That way, one Canvas can be used to contain a ProgressBar bar
alongside whatever else the developer wants to draw. Here are the
basic steps to adding an AMDProgressBarEmbed to a component:
- Create an AMDProgressBarEmbed, passing the component in which
the bar should be embeddedas the
parent parameter.
- Position it within the component using
reshape().
- Important: call the bar's
paint() method
from within the component's paint, passing the
Graphics object that the bar should paint in.
Note that when the bar needs to repaint itself, it will call its
parent's repaint() method. If the parent's
paint() method does not call the bar's
paint() method, the bar will never redraw
A ProgressBar bar looks like this:

Version: 0.90 09 Dec 1996
Author: Adam Doppelt
- See Also:
- AMDProgressBar
-
AMDProgressBarEmbed(Component)
- Constructs a ProgressBar bar.
-
paint(Graphics)
- Paint the ProgressBar bar.
-
reshape(int, int, int, int)
- Resize the ProgressBar bar.
-
setBackgroundColors(Color, Color)
- Set the colors of the top and bottom half of the background inside
the box.
-
setBarColor(Color)
- Set the color of the bar itself.
-
setBorderColors(Color, Color)
- Set the colors of the outer and inner borders on the box.
-
setBoxColors(Color, Color)
- Set the colors of the high and low points of the sine box
surrounding the bar.
-
setFont(Font)
- Set the font of the text.
-
setPercent(double)
- Set the percent of the ProgressBar bar.
-
setSineProperties(int, int)
- Set some properties of the sine box.
-
setText(String)
- Set the text which should be drawn in the center of the bar.
-
setTextColors(Color, Color)
- Set the colors of the text and its shadow.
AMDProgressBarEmbed
public AMDProgressBarEmbed(Component parent)
- Constructs a ProgressBar bar.
- Parameters:
- parent - The AWT parent for this bar. Note that the bar isn't
actually attached to the parent in the usual AWT sense. See the
note at the top for a longer explanation.
reshape
public void reshape(int x,
int y,
int width,
int height)
- Resize the ProgressBar bar.
- Parameters:
- x - The new x location with the parent.
- y - The new y location with the parent.
- width - The new width of the bar, from outer border on the
left to outer border on the right.
- height - The new height of the bar, from outer border on the
top to outer border on the bottom.
paint
public void paint(Graphics g)
- Paint the ProgressBar bar. This should be called from the parent's
paint() method. Otherwise the bar will never
draw.
- Parameters:
- g - The graphics object to draw in.
setPercent
public void setPercent(double percent)
- Set the percent of the ProgressBar bar.
- Parameters:
- percent - The new percent, with 0.0 being completely empty and
1.0 completely full.
setText
public void setText(String text)
- Set the text which should be drawn in the center of the bar.
- Parameters:
- text - The text to draw. If null is passed, the current
percent will be drawn.
setBorderColors
public void setBorderColors(Color outer,
Color inner)
- Set the colors of the outer and inner borders on the box.
- Parameters:
- outer - The color of the 1 pixel border outside the colored box.
- inner - The color of the 1 pixel border just inside the colored box.
setBoxColors
public void setBoxColors(Color a,
Color b)
- Set the colors of the high and low points of the sine box
surrounding the bar. Note that the actual color will walk in a sine
wave between the two colors passed here. The sine wave will crawl
from the upperleft corner, clockwise around the box. If a == b, the
box will be drawn in a single color.
- Parameters:
- a - The color of the first peak of the sine wave.
- b - The color of the other peak of the sine wave.
setBarColor
public void setBarColor(Color bar)
- Set the color of the bar itself.
- Parameters:
- bar - The color of the bar.
setBackgroundColors
public void setBackgroundColors(Color top,
Color bottom)
- Set the colors of the top and bottom half of the background inside
the box.
- Parameters:
- top - The color of the top half of the background.
- bottom - The color of the bottom half of the background.
setTextColors
public void setTextColors(Color text,
Color shadow)
- Set the colors of the text and its shadow.
- Parameters:
- text - The color of the text in the middle of the box.
- shadow - The color of the shadow on the text.
setFont
public void setFont(Font font)
- Set the font of the text.
- Parameters:
- font - The font of the text in the middle of the box.
setSineProperties
public void setSineProperties(int period,
int segmentSize)
- Set some properties of the sine box.
- Parameters:
- period - The distance in pixels between two peaks in the sine
box.
- segmentSize - The size in pixels of each colored segment in
the sine box.