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

Constructor Index

 o AnimatedButton(Image[])
Create an AnimatedButton with the image array as the animation frames.
 o AnimatedButton(Image[], String)
Create an AnimatedButton with the image array as the animation frames and a text label.
 o AnimatedButton(Image[], String, int)
Create an AnimatedButton with the image array as the animation frames, and a text label with position specification.
 o AnimatedButton(Vector)
Create an AnimatedButton with the image vector as the animation frames.
 o AnimatedButton(Vector, String)
Create an AnimatedButton with the image vector as the animation frames and a text label.
 o AnimatedButton(Vector, String, int)
Create an AnimatedButton with the image vector as the animation frames, and a text label with position specification.

Method Index

 o action(Event, Object)
Action routine is called when the left mouse button is pressed and released.
 o mouseEnter(Event, int, int)
Mouse enter event starts an animation sequence.
 o mouseExit(Event, int, int)
Mouse exit event terminates the current animation sequence.
 o paint(Graphics)
Paint AnimatedButton.
 o run()
Run method of the Runnable interface.
 o setDelay(int)
Set the delay between animation frames in miniseconds.
 o start()
Start the animation sequence.
 o stop()
Stop the animation.
 o update(Graphics)
Override the default update to avoid flickering.

Constructors

 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.

Methods

 o 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.
 o 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.
 o 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.
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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