• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Applet Image Animation

 
Greenhorn
Posts: 4
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi !
Please check this out .what is the problem with the following code ? I have tried so much but i don't get it...


import java.awt.*;
import java.applet.*;


public class Animate extends Applet implements Runnable{
int count;
Thread timer;
Image pictures[]=new Image[1];

public void init(){
count=0;
pictures[0]=getImage(getCodeBase(),"green.jpeg");
}

public void start(){
if(timer==null){
timer=new Thread(this);
timer.start();
}
}
public void paint(Graphics g){
g.drawImage(pictures[count],0,0,this);
}

public void run(){
while(isActive()){
try{
repaint();
Thread.sleep(1000);
}catch(Exception e){
e.printStackTrace();
}
}
timer=null;
}
}
This is the code for Animation of Images in the Applet. But it doesn't even draw a single image.
when I execute the Applet in the browser it shows nothing..
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Your image was not found. Could you try something like this to load the image:

Is it better?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic