473,413 Members | 1,833 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

Animating an image in an Applet

Hi ive decided to make an applet where i would like my favorite player ed reed to run accross the screen with the ball in his hand, and i was wondering how i can animate him to do that..ive used the repaint function with a try sleep before so thats all i really am not sure how to do.. what would be a base code for this? im sure its hard if sice you dont have the file, but mabye you can give me a little back round

thanks


Expand|Select|Wrap|Line Numbers
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import java.applet.*;
  4. import javax.swing.*;
  5. public class applet311 extends JApplet
  6. {
  7.  Thread t = new Thread();;
  8.  
  9.  
  10.  
  11.  
  12.  
  13.     Image image; //an 'Image' object
  14.  
  15.  
  16. public void init()
  17. {
  18.  
  19. image = getImage(getCodeBase(), "EdReed_large.gif");
  20. }
  21. public void paint(Graphics g)
  22. {
  23.  
  24. g.setColor(Color.green);
  25. g.fillRect(0,0,500,500);
  26.  
  27. for( int a=0;a<=1000;a+=10)
  28. {
  29. g.setColor(Color.white);
  30. g.drawLine(0,10+a,500,10+a);
  31. g.drawImage(image, 400, 0, this);
  32.  
  33.  
  34.  
  35.  
  36. }
  37.  
  38. }
  39.  
Sep 30 '08 #1
2 1444
You should take a quick look at THIS link. I think that is is exactly what you need to get going :)
Sep 30 '08 #2
thank you for providing me with the link
Sep 30 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: takeiteasy | last post by:
Hello everyone, I've got a question about programming by using Java applet and the question is : Design a web page containing an applet that simply switches from one image to the next with some...
2
by: final farewell | last post by:
Hello I am trying to do a simple java applet which loads image from a specified url. Here is the code I have now, but it cant seem to work. import java.applet.*; import java.awt.*;
1
by: kummu4help | last post by:
hi, i want to draw rectangle based on mousedrag event. if user dragging the mouse, then the rectangle on the applet should increase or decrease basing on current mouse coordinates. i have the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.