Class tea.set.AnimatedButton
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. @see ImageButton.
The label is not animated.
- See Also:
- ImageButton, ButtonFilter
-
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.
-
AnimatedButton(Vector)
- Create an AnimatedButton with the image vector as the animation
frames.
-
AnimatedButton(Vector, String)
- Create an AnimatedButton with the image vector as the animation
frames and a text label.
-
AnimatedButton(Vector, String, int)
- Create an AnimatedButton with the image vector as the animation
frames, and a text label with position specification.
-
action(Event, Object)
- Action routine is called when the left mouse button is pressed and
released.
-
mouseEnter(Event, int, int)
- Mouse enter event starts an animation sequence.
-
mouseExit(Event, int, int)
- Mouse exit event terminates the current animation sequence.
-
paint(Graphics)
- Paint AnimatedButton.
-
run()
- Run method of the Runnable interface.
-
setDelay(int)
- Set the delay between animation frames in miniseconds.
-
start()
- Start the animation sequence.
-
stop()
- Stop the animation.
-
update(Graphics)
- Override the default update to avoid flickering.
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(Vector iv)
- Create an AnimatedButton with the image vector as the animation
frames. The images don't need to be loaded at the time of the
creation of button.
- Parameters:
- iv - a vector of java.awt.Image. Each image is a frame
in the animation.
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 animatino 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(Vector iv,
String label)
- Create an AnimatedButton with the image vector as the animation
frames and a text label.
Add a text label to the button to be displayed with
the graphics. Same as AnimatedButton(Image[], String).
- Parameters:
- iv - a vector 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.
AnimatedButton
public AnimatedButton(Vector iv,
String label,
int pos)
- Create an AnimatedButton with the image vector 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 - a vector 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.
setDelay
public 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.
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.
action
public boolean action(Event e,
Object w)
- Action routine is called when the left mouse button is pressed and
released. Argument object contains a reference to AnimatedButton
self.
- Overrides:
- action in class ImageButton
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
mouseEnter
public boolean mouseEnter(Event e,
int x,
int y)
- 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.
- Parameters:
- e - event object.
- x - x coordinate of the mouse click point.
- y - y coordinate of the mouse click point.
- Overrides:
- mouseEnter in class Component
mouseExit
public boolean mouseExit(Event e,
int x,
int y)
- Mouse exit event terminates the current animation sequence.
- Parameters:
- e - event object.
- x - x coordinate of the mouse click point.
- y - y coordinate of the mouse click point.
- Overrides:
- mouseExit 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