Sprite Animation Image to use

   import javax.swing.JFrame;

public class Sprite extends JFrame {

    public Sprite()
    {
        add(new SpriteBoard());
        setTitle("Sprite");
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setSize(400,600);
        setLocationRelativeTo(null);
        setVisible(true);
        setResizable(false);
    }

    public static void main(String[] args) {
        new Sprite();
    }
}
  

 
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Toolkit;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import javax.swing.Timer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Random;

import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.imageio.*;
import java.awt.image.*;
import java.io.*;


public class SpriteBoard  extends JPanel implements Runnable, MouseListener
{
boolean ingame = true;
private Dimension d;
int BOARD_WIDTH=500;
int BOARD_HEIGHT=500;
BufferedImage img;
BufferedImage sprite;
 private Thread animator;
 int count = 0;
 int iX = 2;
        int iY = 2;
        int iXDist = 310;
        int iYDist = 370;
         int[][] imgPoints = {{ 2,2,310,370},
                            {314,2,722,370},
                            {716,2,945,370},
                            {949,2 , 1269, 370}};
 
    public SpriteBoard()
    {
                 addKeyListener(new TAdapter());
         addMouseListener(this);
        setFocusable(true);
        d = new Dimension(BOARD_WIDTH, BOARD_HEIGHT);
        setBackground(Color.black);
       
                    
                    try {
            img = ImageIO.read(this.getClass().getResource("runner.png"));
           // sprite = ImageIO.read(this.getClass().getResource("spritesheet.png"));
            } catch (IOException e) {
            System.out.println("Image could not be read");
            // System.exit(1);
            }
            
            if (animator == null || !ingame) {
            animator = new Thread(this);
            animator.start();
            }
                    
  
        setDoubleBuffered(true);
    }
    
    public void paint(Graphics g)
{
super.paint(g);

g.setColor(Color.white);
g.fillRect(0, 0, d.width, d.height);
    if (ingame) {
        //310 by 370
        int x = 100;
        int y = 100;
        int xDist = 103;
        int yDist = 123;
    
        
       
        
     g.drawImage(img,x, y, x+xDist, y + yDist,imgPoints[count][0], imgPoints[count][1], imgPoints[count][2], imgPoints[count][3] ,null);
     //drawImage(Image img,int dstx1, int dsty1, int dstx2, int dsty2,int srcx1, int srcy1, int srcx2, int srcy2,
       //    ImageObserver observer);
    
   
    }
Toolkit.getDefaultToolkit().sync();
g.dispose();
}
private class TAdapter extends KeyAdapter {

public void keyReleased(KeyEvent e) {
// player.keyReleased(e);
 int key = e.getKeyCode();
     
}

public void keyPressed(KeyEvent e) {
//System.out.println( e.getKeyCode());
   // message = "Key Pressed: " + e.getKeyCode();
    int key = e.getKeyCode();
        if(key==39){
          
        }
        
       

}

}




public void mousePressed(MouseEvent e) {
    int x = e.getX();
     int y = e.getY();

}

public void mouseReleased(MouseEvent e) {

}

public void mouseEntered(MouseEvent e) {

}

public void mouseExited(MouseEvent e) {

}

public void mouseClicked(MouseEvent e) {

}

public void run() {

long beforeTime, timeDiff, sleep;

beforeTime = System.currentTimeMillis();
 int animationDelay = 500;
 long time = 
            System.currentTimeMillis();
    while (true) {//infinite loop
     // spriteManager.update();
      repaint();
      try {
        time += animationDelay;
        Thread.sleep(Math.max(0,time - 
          System.currentTimeMillis()));
      }catch (InterruptedException e) {
        System.out.println(e);
      }//end catch
    }//end while loop

    


}//end of run

}//end of class