I have a programm that runs an applet. It loads a series of images and paints them. The problem is the programm seems to not to paint the images in the same order..or rather it skips some of the images....what can i do?
I tried using the udate(screen) function but the screen bacame very flickerig. And also not all the images were painted..please help ..here is the code.The images are name image1.gif image2.gif etc

import java.awt.*;
 
  public class Animate extends javax.swing.JApplet
    implements Runnable {
 
   Image[] picture = new Image[7];
   int totalPictures = 0;
   int current = 0;
   Thread runner;
   int pause = 500;
   
   Toolkit toolkit = Toolkit.getDefaultToolkit();
   public void init() {
     for (int i = 0; i <= 6; i++) {
       String imageText = null;
            totalPictures++;
          picture[i] = toolkit.getImage("image" + i + ".gif");
      
        }
     String pauseText = null;
     pauseText = getParameter("pause");
     if (pauseText != null) {
       pause = Integer.parseInt(pauseText);
     }
   }

   public void paint(Graphics screen) {
     super.paint(screen);
    Graphics2D screen2D = (Graphics2D) screen;
  Image myimage =  picture[current];
     if (picture[current] != null)
             screen2D.drawImage(picture[current], 0, 0, this);
  if (current == 6)
             update(screen2D);
  
      }
   public void start() {
     if (runner == null) {
       runner = new Thread(this);
       runner.start();
     }
   }

   public void run() {
     Thread thisThread = Thread.currentThread();
     while (runner == thisThread) {
       repaint();
        current++;
       if (current >= totalPictures)
         current = 0;
       try {
      //   Thread.sleep(pause);
           Thread.sleep(400);
       } catch (InterruptedException e) { }
     }
   }

   public void stop() {
     if (runner != null) {
       runner = null;
     }
   }
 }

Try to visit this site tutorialized.com.
It has everything you need to know about animation.
Try to use also or download Maya for animation, it's really good.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.