How to Use Animated Sprites in Eclipse
Animated sprites let you display images that move in your Java applications. Eclipse is the main Java application that lets you create servlets, desktop apps and Web apps. Animated sprites are typically used in Web projects, but you can use them in any Java project. To use the sprites, you must insert the animation into the section of code that places objects in the main Java form.
Instructions
-
-
1
Open the Eclipse software and open the project you want to edit. Double-click the Java source code file you want to use to display the animation.
-
2
Add the libraries for the animation Java functions. Copy and paste the following code to the top of the file:
import org.eclipse.swt.graphics.*;
-
-
3
Set up the animation sprite for your form. The following code sets up the GIF file named "sprite.gif":
ImageData image = new Image("sprite.gif");
-
4
Display the image to the screen. Add the following code to add it to your user's screen:
GC screen = new GC(image);
-
5
Save the changes and click the Eclipse "Run" button to run the code in the Java debugger.
-
1