Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

index going out of bounds

807588Mar 28 2009 — edited Mar 28 2009
I have created a jcombbox when clicked it inserts information into the appropriate textfields, there is also a remove function so that when the remove button is pressed the information is removed from the array, but when I try and remove the last piece of information from the array it comes up with this message

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1

i tried correcting the issue myself, but to no avail.
  if (e.getSource() == RemoveMethod)
        {
            zclass.getMethods().getZMethod().remove(MethodSelect.getSelectedIndex());
            
            MethodSelect.removeItemAt(MethodSelect.getSelectedIndex());
            
            MethodName.setText("");
            MethodReturnType.setText("");
            MethodVisibility.setText("");
            MethodParameters.setText("");
            MethodAbstract.setSelected(false);
            MethodStatic.setSelected(false);
            
        }
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 25 2009
Added on Mar 28 2009
3 comments
96 views