when ever i try to compile/run my game in eclipse it says this

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at OurGame.Board.checkCollisions(Board.java:78)
at OurGame.Board.actionPerformed(Board.java:40)
at javax.swing.Timer.fireActionPerformed(Unknown Source)
at javax.swing.Timer$DoPostEvent.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

i have fixed this temporarily by exiting out and opening the ide again but its reallly annoying and doesn't work some times.

Recommended Answers

All 10 Replies

Have you tried reading the error? The problem is when you run your code. Read the errors that you get:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at OurGame.Board.checkCollisions(Board.java:78)

At the file: Board.java line 78, in the method checkCollisions you are trying to use an object which is null. (java.lang.NullPointerException)
Try to print the objects that you are using and see which one is null and make sure you initialize it.

If you still having problems you can post your code (the method checkCollisions) so we can take a better look.

why does this only happen sometimes could it be its loading them in the wrong order?

Have you tried reading the error? The problem is when you run your code. Read the errors that you get:

At the file: Board.java line 78, in the method checkCollisions you are trying to use an object which is null. (java.lang.NullPointerException)
Try to print the objects that you are using and see which one is null and make sure you initialize it

why does this only happen sometimes could it be its loading them in the wrong order?

Probably because it happens at Run Time. Meaning that sometimes the object that you use has value, and sometimes it doesn't.
Maybe you have some if statements and there is a case where something is not being initialized.

Do you have some code?

heres the code where the errors are

package OurGame;

import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;

import javax.swing.*;

public class Board extends JPanel implements ActionListener, Runnable {
	Dude p;
	public Image img;
	Timer time;
	static int v = 120;
	Thread animator;
	Enemy en, en2, en3, en4, en5, en6;
	Boss boss1;
	boolean a = false;
	boolean done2 = false;
	boolean  lost = false;	
	
	static Font font = new Font("SanSerif", Font.BOLD, 24);
	public Board() {
		p = new Dude();
		addKeyListener(new AL());
		setFocusable(true);
		ImageIcon i = new ImageIcon("JavaGame1/bs1.png");
		img = i.getImage();
		time = new Timer(5, this);
		time.start();
		en = new Enemy(700, 100, "JavaGame1/enimie.png");
		en2 = new Enemy(1200, 100, "JavaGame1/enimie.png");
		en3 = new Enemy(1500, 100, "JavaGame1/enimie.png");
		en4 = new Enemy(1700, 100, "JavaGame1/enimie.png");
		en5 = new Enemy(1900, 100, "JavaGame1/enimie.png");
		en6 = new Enemy(2100, 100, "JavaGame1/enimie.png");
		boss1 = new Boss(2300, 100, "JavaGame1/bz.png");
	}

	public void actionPerformed(ActionEvent e) {
		checkCollisions();
		//System.out.println(p.x);
		ArrayList bullets = Dude.getBullets();
		for (int w = 0; w < bullets.size(); w++)
		{
			Bullet m = (Bullet) bullets.get(w);
			if (m.getVisible() == true)
			m.move();
			else
				bullets.remove(w);
		}
		
		p.move();
		
		if (p.x > 200)
			en.move(p.getdx(), p.getLeft());
		if (p.x> 500)
			en2.move(p.getdx(), p.getLeft());
		if (p.x> 800)
			en3.move(p.getdx(), p.getLeft());
		if (p.x> 1100)
			en4.move(p.getdx(), p.getLeft());
		if (p.x> 1200)
			en5.move(p.getdx(), p.getLeft());
		if (p.x> 1300)
			en6.move(p.getdx(), p.getLeft());
		if (p.x> 1400)
			boss1.move(p.getdx(), p.getLeft());
		repaint();
	}

	public void checkCollisions(){
	        Rectangle r1 = en.getBounds();
	        Rectangle r2 = en2.getBounds();
	        Rectangle r3 = en3.getBounds();
	        Rectangle r4 = en4.getBounds();
	        Rectangle r5 = en5.getBounds();
	        Rectangle r6 = en6.getBounds();
	        Rectangle r7 = boss1.getBounds();
	        ArrayList bullets = Dude.getBullets();
	        for (int w = 0; w < bullets.size(); w++){
	                Bullet m = (Bullet) bullets.get(w);
	                Rectangle m1 = m.getBounds();
	                if (r1.intersects(m1) && en.Alive())
	                {
	                	m.visible = false;
	                	en.health -= 50;
                		if(en.health <= 0){
                        en.isAlive = false;
                        p.score += 100;
                		}
	                }
	                else if (r2.intersects(m1) && en2.Alive())
	                {
	                	m.visible = false;
	                	en2.health -= 45;
                		if(en2.health <= 0){
                        en2.isAlive = false;
                        p.score += 100;
                		}
	                }
	                else if (r3.intersects(m1)&& en3.Alive()){
	                		m.visible = false;
	                		en3.health -= 40;
	                		if(en3.health <= 0){
	                        en3.isAlive = false;
	                        p.score += 100;
	                		}
	                }
	                else if (r4.intersects(m1)&& en4.Alive()){
                		m.visible = false;
                		en4.health -= 35;
                		if(en4.health <= 0){
                        en4.isAlive = false;
                        p.score += 100;
                		}
	                }
	                else if (r5.intersects(m1)&& en5.Alive()){
                		m.visible = false;
                		en5.health -= 35;
                		if(en5.health <= 0){
                        en5.isAlive = false;
                        p.score += 100;
                		}
	                }
	                else if (r6.intersects(m1)&& en6.Alive()){
                		m.visible = false;
                		en6.health -= 35;
                		if(en6.health <= 0){
                        en6.isAlive = false;
                        p.score += 100;
                		}
	                }
	                else if (r7.intersects(m1)&& boss1.Alive()){
                		m.visible = false;
                		boss1.health -= 40;
                		if(boss1.health <= 0){
                        boss1.isAlive = false;
                        p.score += 600;
                		}
	                }
	        }
	        Rectangle d = p.getBounds();
	        if (d.intersects(r1) && en.Alive() ||
	        	d.intersects(r2) && en2.Alive() ||
	        	d.intersects(r3) && en3.Alive() ||
	        	d.intersects(r4) && en4.Alive() ||
	        	d.intersects(r5) && en5.Alive() ||
	        	d.intersects(r6) && en6.Alive() ||
	        	d.intersects(r7) && boss1.Alive())
	                lost = true;
	}
	
	public void paint(Graphics g) {
		if (p.dy == 1 && done2 == false) {
			done2 = true;
			animator = new Thread(this);
			animator.start();
		}

		super.paint(g);
		Graphics2D g2d = (Graphics2D) g;

		if ((p.getX() - 590) % 2400 == 0)// p.getX() == 590 || p.getX() == 2990)...
			p.nx = 0;
		if ((p.getX() - 1790) % 2400 == 0)// p.getX() == 1790 || p.getX() == 4190)...
			p.nx2 = 0;

		g2d.drawImage(img, 685 - p.getnX2(), 0, null);
		if (p.getX() > 590) {
			g2d.drawImage(img, 685 - p.getnX(), 0, null);
		}
		g2d.drawImage(p.getImage(), p.left, v, null);

		if (p.getdx() == -1) {
			g2d.drawImage(img, 685 - p.getnX2(), 0, null);
			g2d.drawImage(p.getImage(), p.left, v, null);
		}
		
		ArrayList bullets = Dude.getBullets();
		for (int w = 0; w < bullets.size(); w++)
		{
			Bullet m = (Bullet) bullets.get(w);
			g2d.drawImage(m.getImage(),m.getX(), m.getY(), null);
		}
		g2d.setFont(font);
		g2d.setColor(Color.BLUE);
		g2d.drawString("Ammo left: " + p.ammo, 500, 20);
		g2d.drawString("Score: " + p.score, 500, 40);
		if(lost){
			g2d.drawString("YOU LOSE", 300, 182);
			p.ammo = 0;
		}
		if (p.x > 200)
			if (en.Alive() == true)
				g2d.drawImage(en.getImage(), en.getX(), en.getY(), null);
		if (p.x > 600)
			if (en2.Alive() == true)
				g2d.drawImage(en2.getImage(), en2.getX(), en2.getY(), null);
		if (p.x > 800)
			if (en3.Alive() == true)
				g2d.drawImage(en3.getImage(), en3.getX(), en3.getY(), null);
		if (p.x > 1000)
			if (en4.Alive() == true)
				g2d.drawImage(en4.getImage(), en4.getX(), en4.getY(), null);
		if (p.x > 1100)
			if (en5.Alive() == true)
				g2d.drawImage(en5.getImage(), en5.getX(), en5.getY(), null);
		if (p.x > 1200)
			if (en6.Alive() == true)
				g2d.drawImage(en6.getImage(), en6.getX(), en6.getY(), null);
		if (p.x > 1300)
			if (boss1.Alive() == true)
				g2d.drawImage(boss1.getImage(), boss1.getX(), boss1.getY(), null);
	}

	private class AL extends KeyAdapter {
		public void keyReleased(KeyEvent e) {
			p.keyReleased(e);
		}

		public void keyPressed(KeyEvent e) {
			p.keyPressed(e);
		}
	}

	boolean h = false;
	boolean done = false;

	public void cycle() {

		if (h == false)
			v--;
		if (v == 65)
			h = true;
		if (h == true && v <= 120) {
			v++;
			if (v == 120) {
				done = true;
			}
		}
	}

	public void run() {

		long beforeTime, timeDiff, sleep;

		beforeTime = System.currentTimeMillis();

		while (done == false) {

			cycle();

			timeDiff = System.currentTimeMillis() - beforeTime;
			sleep = 10 - timeDiff;

			if (sleep < 0)
				sleep = 2;
			try {
				Thread.sleep(sleep);
			} catch (InterruptedException e) {
			}

			beforeTime = System.currentTimeMillis();
		}
		done = false;
		h = false;
		done2 = false;
	}

}

Where exactly is the error at the checkCollisions method? Can you mark it somehow at the code that you posted. Also go to the line that the error says and print everything that you use there.

heres the errors

package OurGame;

import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;

import javax.swing.*;

public class Board extends JPanel implements ActionListener, Runnable {
	Dude p;
	public Image img;
	Timer time;
	static int v = 120;
	Thread animator;
	Enemy en, en2, en3, en4, en5, en6;
	Boss boss1;
	boolean a = false;
	boolean done2 = false;
	boolean  lost = false;	
	
	static Font font = new Font("SanSerif", Font.BOLD, 24);
	public Board() {
		p = new Dude();
		addKeyListener(new AL());
		setFocusable(true);
		ImageIcon i = new ImageIcon("JavaGame1/bs1.png");
		img = i.getImage();
		time = new Timer(5, this);
		time.start();
		en = new Enemy(700, 100, "JavaGame1/enimie.png");
		en2 = new Enemy(1200, 100, "JavaGame1/enimie.png");
		en3 = new Enemy(1500, 100, "JavaGame1/enimie.png");
		en4 = new Enemy(1700, 100, "JavaGame1/enimie.png");
		en5 = new Enemy(1900, 100, "JavaGame1/enimie.png");
		en6 = new Enemy(2100, 100, "JavaGame1/enimie.png");
		boss1 = new Boss(2300, 100, "JavaGame1/bz.png");
	}

	public void actionPerformed(ActionEvent e) {
		checkCollisions(); // second error here
		//System.out.println(p.x);
		ArrayList bullets = Dude.getBullets();
		for (int w = 0; w < bullets.size(); w++)
		{
			Bullet m = (Bullet) bullets.get(w);
			if (m.getVisible() == true)
			m.move();
			else
				bullets.remove(w);
		}
		
		p.move();
		
		if (p.x > 200)
			en.move(p.getdx(), p.getLeft());
		if (p.x> 500)
			en2.move(p.getdx(), p.getLeft());
		if (p.x> 800)
			en3.move(p.getdx(), p.getLeft());
		if (p.x> 1100)
			en4.move(p.getdx(), p.getLeft());
		if (p.x> 1200)
			en5.move(p.getdx(), p.getLeft());
		if (p.x> 1300)
			en6.move(p.getdx(), p.getLeft());
		if (p.x> 1400)
			boss1.move(p.getdx(), p.getLeft());
		repaint();
	}

	public void checkCollisions(){
	        Rectangle r1 = en.getBounds();
	        Rectangle r2 = en2.getBounds();
	        Rectangle r3 = en3.getBounds();
	        Rectangle r4 = en4.getBounds();
	        Rectangle r5 = en5.getBounds();
	        Rectangle r6 = en6.getBounds();
	        Rectangle r7 = boss1.getBounds(); // first error here
	        ArrayList bullets = Dude.getBullets();
	        for (int w = 0; w < bullets.size(); w++){
	                Bullet m = (Bullet) bullets.get(w);
	                Rectangle m1 = m.getBounds();
	                if (r1.intersects(m1) && en.Alive())
	                {
	                	m.visible = false;
	                	en.health -= 50;
                		if(en.health <= 0){
                        en.isAlive = false;
                        p.score += 100;
                		}
	                }
	                else if (r2.intersects(m1) && en2.Alive())
	                {
	                	m.visible = false;
	                	en2.health -= 45;
                		if(en2.health <= 0){
                        en2.isAlive = false;
                        p.score += 100;
                		}
	                }
	                else if (r3.intersects(m1)&& en3.Alive()){
	                		m.visible = false;
	                		en3.health -= 40;
	                		if(en3.health <= 0){
	                        en3.isAlive = false;
	                        p.score += 100;
	                		}
	                }
	                else if (r4.intersects(m1)&& en4.Alive()){
                		m.visible = false;
                		en4.health -= 35;
                		if(en4.health <= 0){
                        en4.isAlive = false;
                        p.score += 100;
                		}
	                }
	                else if (r5.intersects(m1)&& en5.Alive()){
                		m.visible = false;
                		en5.health -= 35;
                		if(en5.health <= 0){
                        en5.isAlive = false;
                        p.score += 100;
                		}
	                }
	                else if (r6.intersects(m1)&& en6.Alive()){
                		m.visible = false;
                		en6.health -= 35;
                		if(en6.health <= 0){
                        en6.isAlive = false;
                        p.score += 100;
                		}
	                }
	                else if (r7.intersects(m1)&& boss1.Alive()){
                		m.visible = false;
                		boss1.health -= 40;
                		if(boss1.health <= 0){
                        boss1.isAlive = false;
                        p.score += 600;
                		}
	                }
	        }
	        Rectangle d = p.getBounds();
	        if (d.intersects(r1) && en.Alive() ||
	        	d.intersects(r2) && en2.Alive() ||
	        	d.intersects(r3) && en3.Alive() ||
	        	d.intersects(r4) && en4.Alive() ||
	        	d.intersects(r5) && en5.Alive() ||
	        	d.intersects(r6) && en6.Alive() ||
	        	d.intersects(r7) && boss1.Alive())
	                lost = true;
	}
	
	public void paint(Graphics g) {
		if (p.dy == 1 && done2 == false) {
			done2 = true;
			animator = new Thread(this);
			animator.start();
		}

		super.paint(g);
		Graphics2D g2d = (Graphics2D) g;

		if ((p.getX() - 590) % 2400 == 0)// p.getX() == 590 || p.getX() == 2990)...
			p.nx = 0;
		if ((p.getX() - 1790) % 2400 == 0)// p.getX() == 1790 || p.getX() == 4190)...
			p.nx2 = 0;

		g2d.drawImage(img, 685 - p.getnX2(), 0, null);
		if (p.getX() > 590) {
			g2d.drawImage(img, 685 - p.getnX(), 0, null);
		}
		g2d.drawImage(p.getImage(), p.left, v, null);

		if (p.getdx() == -1) {
			g2d.drawImage(img, 685 - p.getnX2(), 0, null);
			g2d.drawImage(p.getImage(), p.left, v, null);
		}
		
		ArrayList bullets = Dude.getBullets();
		for (int w = 0; w < bullets.size(); w++)
		{
			Bullet m = (Bullet) bullets.get(w);
			g2d.drawImage(m.getImage(),m.getX(), m.getY(), null);
		}
		g2d.setFont(font);
		g2d.setColor(Color.BLUE);
		g2d.drawString("Ammo left: " + p.ammo, 500, 20);
		g2d.drawString("Score: " + p.score, 500, 40);
		if(lost){
			g2d.drawString("YOU LOSE", 300, 182);
			p.ammo = 0;
			
		}
		if (p.x > 200)
			if (en.Alive() == true)
				g2d.drawImage(en.getImage(), en.getX(), en.getY(), null);
		if (p.x > 600)
			if (en2.Alive() == true)
				g2d.drawImage(en2.getImage(), en2.getX(), en2.getY(), null);
		if (p.x > 800)
			if (en3.Alive() == true)
				g2d.drawImage(en3.getImage(), en3.getX(), en3.getY(), null);
		if (p.x > 1000)
			if (en4.Alive() == true)
				g2d.drawImage(en4.getImage(), en4.getX(), en4.getY(), null);
		if (p.x > 1100)
			if (en5.Alive() == true)
				g2d.drawImage(en5.getImage(), en5.getX(), en5.getY(), null);
		if (p.x > 1200)
			if (en6.Alive() == true)
				g2d.drawImage(en6.getImage(), en6.getX(), en6.getY(), null);
		if (p.x > 1300)
			if (boss1.Alive() == true)
				g2d.drawImage(boss1.getImage(), boss1.getX(), boss1.getY(), null);
	}

	private class AL extends KeyAdapter {
		public void keyReleased(KeyEvent e) {
			p.keyReleased(e);
		}

		public void keyPressed(KeyEvent e) {
			p.keyPressed(e);
		}
	}

	boolean h = false;
	boolean done = false;

	public void cycle() {

		if (h == false)
			v--;
		if (v == 65)
			h = true;
		if (h == true && v <= 120) {
			v++;
			if (v == 120) {
				done = true;
			}
		}
	}

	public void run() {

		long beforeTime, timeDiff, sleep;

		beforeTime = System.currentTimeMillis();

		while (done == false) {

			cycle();

			timeDiff = System.currentTimeMillis() - beforeTime;
			sleep = 10 - timeDiff;

			if (sleep < 0)
				sleep = 2;
			try {
				Thread.sleep(sleep);
			} catch (InterruptedException e) {
			}

			beforeTime = System.currentTimeMillis();
		}
		done = false;
		h = false;
		done2 = false;
	}

}

Have you tried to print the values of the objects you are using?
If you get a NullPointerException at the line:

Rectangle r7 = boss1.getBounds(); // first error here

Then probably, boss1 is null. I find that very hard to believe since you initialize it in the constructor! Since you correctly create the Enemies, the Boss should work.
Can you try this:

System.out.println("boss1="+boss1);
System.out.println("boss1.getBounds()="+boss1.getBounds());
Rectangle r7 = boss1.getBounds();
System.out.println("r7="+r7);

And post again the output, the error, and a small part of the code that you get the error

Heres the working output

boss1=OurGame.Boss@30ec4a87
boss1.getBounds()=java.awt.Rectangle[x=2300,y=100,width=10,height=100]
r7=java.awt.Rectangle[x=2300,y=100,width=10,height=100]

heres the error/non working output

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at OurGame.Board.checkCollisions(Board.java:72)
at OurGame.Board.actionPerformed(Board.java:40)
at javax.swing.Timer.fireActionPerformed(Unknown Source)
at javax.swing.Timer$DoPostEvent.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

and heres the small(ish) part of code where the error is

public void actionPerformed(ActionEvent e) {
		checkCollisions();
		//System.out.println(p.x);
		ArrayList bullets = Dude.getBullets();
		for (int w = 0; w < bullets.size(); w++)
		{
			Bullet m = (Bullet) bullets.get(w);
			if (m.getVisible() == true)
			m.move();
			else
				bullets.remove(w);
		}
		
		p.move();
		
		if (p.x > 200)
			en.move(p.getdx(), p.getLeft());
		if (p.x> 500)
			en2.move(p.getdx(), p.getLeft());
		if (p.x> 800)
			en3.move(p.getdx(), p.getLeft());
		if (p.x> 1100)
			en4.move(p.getdx(), p.getLeft());
		if (p.x> 1200)
			en5.move(p.getdx(), p.getLeft());
		if (p.x> 1300)
			en6.move(p.getdx(), p.getLeft());
		if (p.x> 1400)
			boss1.move(p.getdx(), p.getLeft());
		repaint();
	}

	public void checkCollisions(){
	        Rectangle r1 = en.getBounds();
	        Rectangle r2 = en2.getBounds();
	        Rectangle r3 = en3.getBounds();
	        Rectangle r4 = en4.getBounds();
	        Rectangle r5 = en5.getBounds();
	        Rectangle r6 = en6.getBounds();
	        System.out.println("boss1="+boss1);
	        System.out.println("boss1.getBounds()="+boss1.getBounds());
	        Rectangle r7 = boss1.getBounds();
	        System.out.println("r7="+r7);
	        ArrayList bullets = Dude.getBullets();
	        for (int w = 0; w < bullets.size(); w++){
	                Bullet m = (Bullet) bullets.get(w);
	                Rectangle m1 = m.getBounds();
	                if (r1.intersects(m1) && en.Alive())
	                {
	                	m.visible = false;
	                	en.health -= 50;
                		if(en.health <= 0){
                        en.isAlive = false;
                        p.score += 100;
                		}
	                }
	                else if (r2.intersects(m1) && en2.Alive())
	                {
	                	m.visible = false;
	                	en2.health -= 45;
                		if(en2.health <= 0){
                        en2.isAlive = false;
                        p.score += 100;
                		}
	                }
	                else if (r3.intersects(m1)&& en3.Alive()){
	                		m.visible = false;
	                		en3.health -= 40;
	                		if(en3.health <= 0){
	                        en3.isAlive = false;
	                        p.score += 100;
	                		}
	                }
	                else if (r4.intersects(m1)&& en4.Alive()){
                		m.visible = false;
                		en4.health -= 35;
                		if(en4.health <= 0){
                        en4.isAlive = false;
                        p.score += 100;
                		}
	                }
	                else if (r5.intersects(m1)&& en5.Alive()){
                		m.visible = false;
                		en5.health -= 35;
                		if(en5.health <= 0){
                        en5.isAlive = false;
                        p.score += 100;
                		}
	                }
	                else if (r6.intersects(m1)&& en6.Alive()){
                		m.visible = false;
                		en6.health -= 35;
                		if(en6.health <= 0){
                        en6.isAlive = false;
                        p.score += 100;
                		}
	                }
	                else if (r7.intersects(m1)&& boss1.Alive()){
                		m.visible = false;
                		boss1.health -= 40;
                		if(boss1.health <= 0){
                        boss1.isAlive = false;
                        p.score += 600;
                		}
	                }
	        }
	        Rectangle d = p.getBounds();
	        if (d.intersects(r1) && en.Alive() ||
	        	d.intersects(r2) && en2.Alive() ||
	        	d.intersects(r3) && en3.Alive() ||
	        	d.intersects(r4) && en4.Alive() ||
	        	d.intersects(r5) && en5.Alive() ||
	        	d.intersects(r6) && en6.Alive() ||
	        	d.intersects(r7) && boss1.Alive())
	                lost = true;
	}

Read the error that you get!

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at OurGame.Board.checkCollisions(Board.java:72)

Board.java:72 line 72. Something there is null.
Print everything that you use at that line. And point out in the code that you posted where that line is.

thanks for all the help but i added a thread sleep for 20 millis and it hasn't givin me an error yet ill open a nwe thread if theres another error

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.