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.getX() - b.getRadius() && waiting.getX() <= b.getX() + b.getRadius()
					&& waiting.getY() >= b.getY() - b.getRadius() && waiting.getY() <= b.getY() + 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((double) ballarray.get(ballarray.size()-1).getX());
			originalY.add((double) ballarray.get(ballarray.size()-1).getY());

			//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).getX(), (int) ballarray.get(ballarray.size()-1).getY(), 50, 25);
			chargeDisplay.add(temp);
			add(chargeDisplay.get(chargeDisplay.size()-1));
			temp.setVisible(true);
			repaint();
		}
	}