All Packages Class Hierarchy This Package Previous Next Index
Class tea.set.AnimatedButton
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Canvas
|
+----tea.set.ImageButton
|
+----tea.set.AnimatedButton
- public class AnimatedButton
- extends ImageButton
- implements Runnable
AnimatedButton displays a series of animation images in a button.
It plays an animation sequence when it is first created and when
the mouse pointer moves inside the button. The gif's can be plain
images. The images will be passed through a ButtonFilter to create
a button image. The rate of the animation
can be controlled by setting the delay between frames by
using setDelay() method.
The default size of the button is the size of the first image in
the animation sequence. If the subsequent images have different
size than the first image, they will be scaled to the same size
as the first image. If the button is resized to another size,
such as the case when the button is added to the Center portion
of a panel with BorderLayout, all images will be scaled to the
new size to fill the button area.
AnimatedButton supports a text label to be
displayed as part of the button. The position of the label can
be controlled by position flags. The label is not animated.
The AniamgedButton supports the following preperties in addition to
the properties defined in the ImageButton:
Property Name | Property Type | Description |
Delay | int |
Time delay in miniseconds between animation frames. |
Images | Image (Indexed) |
Animation frames for the AnimatedButton. |
- See Also:
- ImageButton
-
AnimatedButton()
- Construct an empty AnimatedButton.
-
AnimatedButton(Image[])
- Create an AnimatedButton with the image array as the animation
frames.
-
AnimatedButton(Image[], String)
- Create an AnimatedButton with the image array as the animation
frames and a text label.
-
AnimatedButton(Image[], String, int)
- Create an AnimatedButton with the image array as the animation
frames, and a text label with position specification.
-
getDelay()
- Get the delay value.
-
getImages()
- Get the animation frame images array.
-
paint(Graphics)
- Paint AnimatedButton.
-
processMouseEvent(MouseEvent)
- Mouse enter event starts an animation sequence.
-
run()
- Run method of the Runnable interface.
-
setDelay(int)
- Set the delay between animation frames in miniseconds.
-
setImages(Image[])
- Set the animation frame images.
-
start()
- Start the animation sequence.
-
stop()
- Stop the animation.
-
update(Graphics)
- Override the default update to avoid flickering.
AnimatedButton
public AnimatedButton()
- Construct an empty AnimatedButton. AnimatedButton.setImages()
must be called before this component can be used.
AnimatedButton
public AnimatedButton(Image iv[])
- Create an AnimatedButton with the image array as the animation
frames. The images don't need to be loaded at the time of the
creation of button.
- Parameters:
- iv - an array of java.awt.Image for animation frames.
AnimatedButton
public AnimatedButton(Image iv[],
String label)
- Create an AnimatedButton with the image array as the animation
frames and a text label.
Add a text label to the button to be displayed with the
graphics. The label is placed below the image by default. The
default size of the button is the size of the first image in
the animation sequence plus necessary space to hold the text
label. If the button is resized to a size other than the
default size. The images are scaled to fill the area left
over by the label inside the button area.
- Parameters:
- iv - an array of java.awt.Image for animation frames.
- label - a text label to be displayed in the button.
AnimatedButton
public AnimatedButton(Image iv[],
String label,
int pos)
- Create an AnimatedButton with the image array as the animation
frames, and a text label with position specification.
Add a text label at specified position to the button to
be displayed with the graphics. See ImageButton for available
position flags.
- Parameters:
- iv - an array of java.awt.Image for animation frames.
- label - a text label to be displayed in the button.
- pos - the position of the label inside the button. Use
the position flags values.
getImages
public Image[] getImages()
- Get the animation frame images array.
- Returns:
- animation frames.
setImages
public void setImages(Image iv[])
- Set the animation frame images.
setDelay
public synchronized void setDelay(int d)
- Set the delay between animation frames in miniseconds. Setting
the delay larger will make the animation slower.
- Parameters:
- d - the delay between animation frames in miniseconds.
getDelay
public int getDelay()
- Get the delay value. The delay is the number of miniseconds
between frames.
- Returns:
- current delay value.
start
public void start()
- Start the animation sequence. If the mouse pointer is in the button,
the animation will loop indefinitely until the mouse exits. Otherwise
it will execute one sequence and stop.
stop
public void stop()
- Stop the animation. The next call to start() will create a new
thread for animation. The current thread is killed after this
call.
paint
public synchronized void paint(Graphics g)
- Paint AnimatedButton. This function should not be called by the
user. It is called automatically by AWT and animation routine.
- Parameters:
- g - Graphics content of this component.
- Overrides:
- paint in class ImageButton
update
public void update(Graphics g)
- Override the default update to avoid flickering.
- Parameters:
- g - Graphics content of this component.
- Overrides:
- update in class Component
processMouseEvent
public void processMouseEvent(MouseEvent e)
- Mouse enter event starts an animation sequence. If the mouse
pointer stays inside the button, the animation will be played
repeatedly. The animation is stopped when the mouse pointer
moves out of the button area.
Mouse exit event terminates the current animation sequence.
- Parameters:
- e - event object.
- Overrides:
- processMouseEvent in class ImageButton
run
public synchronized void run()
- Run method of the Runnable interface. This is the animation
main loop. The user of AnimatedButton should call start
instead of run() directly.
All Packages Class Hierarchy This Package Previous Next Index