com.jpackages.jtray
Class IconAnimation

java.lang.Object
  extended by com.jpackages.jtray.IconAnimation

public class IconAnimation
extends java.lang.Object

This class defines a list of icons to be used as frames in animation.

The icon animation frames are animated in the order added to this IconAnimation. When all icons have been displayed, it will return to the beginning of this animation and begin again.

If you wish to show an animation once, use showAnimationOnce().

Example:

 IconAnimation iconAnimation = new IconAnimation();
 iconAnimation.addIcon("frame1.ico", ImageFileType.ICO);
 iconAnimation.addIcon("frame2.ico", ImageFileType.ICO);
 iconAnimation.addIcon("frame3.ico", ImageFileType.ICO);
 iconAnimation.addIcon("frame4.ico", ImageFileType.ICO);
 iconAnimation.addIcon("frame5.ico", ImageFileType.ICO);
 iconAnimation.addIcon("frame4.ico", ImageFileType.ICO);
 iconAnimation.addIcon("frame3.ico", ImageFileType.ICO);
 iconAnimation.addIcon("frame2.ico", ImageFileType.ICO);
 iconAnimation.addIcon("frame1.ico", ImageFileType.ICO);

 // jTrayIcon is a JTrayIcon instance
 jTrayIcon.setAnimation(iconAnimation);
 jTrayIcon.startAnimation();
 

Copyright (c) 2001-2008

Author:
JPackages.com

Constructor Summary
IconAnimation()
           
 
Method Summary
 boolean addIcon(java.awt.Image i)
          Adds an icon to this animation from an Image.
 boolean addIcon(javax.swing.ImageIcon i)
          Adds an icon to this animation from an ImageIcon.
 boolean addIcon(java.lang.String filePath, int file_type)
          Adds an icon to this animation from a file.
 boolean addIcon(java.lang.String filePath, int file_type, int index)
          Adds an icon to this animation from a file.
 boolean clearIcons()
          Removes all icons from this animation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IconAnimation

public IconAnimation()
Method Detail

clearIcons

public boolean clearIcons()

Removes all icons from this animation.

Returns:
true if successful, false otherwise. If this IconAnimation is in use, it will return false.

addIcon

public boolean addIcon(java.awt.Image i)

Adds an icon to this animation from an Image.

The Image should have a 1:1 aspect ratio. Recommended image size is 32x32 or 16x16. Color limitations depend on the OS.

Parameters:
i - The Image to use as an icon.
Returns:
true if successful, false otherwise. If this IconAnimation is in use, it will return false.

addIcon

public boolean addIcon(javax.swing.ImageIcon i)

Adds an icon to this animation from an ImageIcon.

The ImageIcon should have a 1:1 aspect ratio. Recommended image size is 32x32 or 16x16. Color limitations depend on the OS.

Parameters:
i - The ImageIcon to use as an icon.
Returns:
true if successful, false otherwise. If this IconAnimation is in use, it will return false.

addIcon

public boolean addIcon(java.lang.String filePath,
                       int file_type)

Adds an icon to this animation from a file.

Parameters:
filePath - The file path to a file that contains an icon. (Such as "icons\\icon1.ico")
file_type - The type of the file. Types are listed in ImageFileType.
Returns:
true if successful, false otherwise. If this IconAnimation is in use, it will return false.

addIcon

public boolean addIcon(java.lang.String filePath,
                       int file_type,
                       int index)

Adds an icon to this animation from a file.

Parameters:
filePath - The file path to a file that contains an icon. (Such as "icons\\icon1.ico")
file_type - The type of the file. Types are listed in ImageFileType.
index - The index of the icon to use. DLLs and EXEs can contain multiple icons accessed by this index. To use this, set file_type to ImageFileType.ICO.
Returns:
true if successful, false otherwise. If this IconAnimation is in use, it will return false.