private void addBallsFromQueue() {
		int numBallsToDoInNextCall = 0;//Used to make the method stop when this number of elements 
		//is in the queue.
		Ball waiting = toAdd.peek();
		boolean spaceFree = true;
		for(Ball b : ballarray){
			if(waiting.getX()>=b.x-b.getRadius()&&waiting.getX()<=b.x+b.getRadius()
					&&waiting.getY()>=b.y-b.getRadius()&&waiting.getY()<=b.y+b.getRadius()
					)spaceFree=false;
		}
		if(!spaceFree){
			/*
			 * This is activated if the ball in the top of toAdd cannot be added during this method call.
			 * If so, then the ball is removed and added at the end of the queue. 
			 * Note: Queue is FIFO
			 * 
			 * numBallsToDoInNextCall is incremented, so to avoid an infinite loop,
			 * and tell the method to stop trying to add the balls which were added to the end of
			 * toAdd (the balls which are going to be added only in the next method call)
			 */
			Ball b = toAdd.poll();
			toAdd.add(b);
			numBallsToDoInNextCall++;

		}
		while(toAdd.size()>numBallsToDoInNextCall){
			Ball b = toAdd.poll();
			ballarray.add(b);
			originalX.add(ballarray.get(ballarray.size()-1).x);
			originalY.add(ballarray.get(ballarray.size()-1).y);
			
			
			
			//Code also adds a label to display the charge on the particle.
			JLabel temp = new JLabel();


			String str = "";
			str+=(int)(ballarray.get(ballarray.size()-1).charge*1000000);
			str+="µ";
			temp.setText(str);
			temp.setBounds((int)ballarray.get(ballarray.size()-1).x, (int)ballarray.get(ballarray.size()-1).y, 50, 25);
			chargeDisplay.add(temp);
			add(chargeDisplay.get(chargeDisplay.size()-1));
			temp.setVisible(true);
			repaint();
			
		}
		
	}