Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Weird error when removing from an array!
String text = showNum.getText(); //showNum is the JTextField
System.out.println(text); //testing purposes
int sN = Integer.parseInt(text);
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. :)
0 · ·