I am writing a phone book and have two issues.
Every time I try to edit or delete a contact I am getting array out of bounds error.
After I add the first contact, every contact after that grows exponentially.
Any major problems that you guys could point out for me research or figure out how to modify.
Thank you again for looking at my code below.
sorry I also have this
When you press Edit it opens the Edit frame (tip: use modal JDialogs instead of JFrames). The Save button is added to this frame. If you press it you clear the list (dList.clear()), then fill it again. But the clearing will also trigger a selection change, as the selection changes from something to nothing (since there is nothing to select).
I've added a quick check against this; above line 239 I added "if (index == -1) return;". This will result into another error, this time on line 90: That's because you're trying to change each entry, but the list model is empty. Change this call into That gets rid of all the errors, but you still loose your selection.
Paul Clapham wrote:That's an awful lot of code for us to look through, when all we really want to know is "What line of code threw that exception?" When you get an exception, the thing to do is to look at the code which caused it. Starting a broad code review isn't the right way to debug.
Sorry first time posting for Java help on a board. It makes sense and will keep this in mind next time!
Rob thanks for taking the time to dig through the long code and provide with help. JDialog is alot easier and a little shorter might I add, thanks for pointing it out.
You guys were a great help! Looking forward to many more posts and hopefully some contribution to up and coming programmers.