i have a problem with ArrayLists in Java. The problem is that when i add an element to the list (pointStorer), the index doesn't increment and every time it resets and remains zero. Here's my code (well it's only the important part of the code):
private ArrayList pointStorer = new ArrayList();
private Point pointValues = new Point();
public void mouseClicked(MouseEvent e) {
pointValues.setLocation(e.getX(), e.getY());
mousePointX = pointValues.x;
mousePointY = pointValues.y;
repaint();
}
public void paint(Graphics g){
pointStorer.add(pointValues);
System.out.println("Index point "+pointStorer.indexOf(pointValues));
}
I use the method .indexOf to know what's the index of the element that i've just added, but it remains always zero.
Thank you in advance for your help.