[code]else if(button.getText().equals("Remove")){
String text = showNum.getText(); //showNum is the JTextField
System.out.println(text); //testing purposes
int sN = Integer.parseInt(text);
System.out.println(sN); //testing
shapes.remove(sN);
}[/code]
Hey, I'm new here!
Anyway, the button works and everything, it's just the body of this particular if statement that I am having trouble with. I am trying to store the JTextField into an int variable, which my test shows that it has done this. However, the remove method is giving me this error "Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index: 3, Size: 3".
The program: It's pretty much a simple, student program where you press buttons and it adds certain shapes to an array of shapes, which adds it to the panel. Right now, I am trying to get it to take an input value through a textField and remove it at that index.
I have spent many hours on this, googling like crazy! If anyone could help, it'd be much appreciated.