As a newbie here I need to know if I code a custom cell renderer for my table, it would solve my problem.
Here is the situation:
I have a table with 2 columns, 2 combo box cells.
I have defined 2 buttons to add and remove the selected rows.
When selecting a combo box cell, it goes to edit mode and if I delete that row and then selecting another row (cell) I am thrown with this exception:
"Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 1 >= 1"
So I thought that a custom cell renderer would solve the problem.
Erm hard-to-tell as there's no code but I don't think the problem is in the rendering, especially if you can already see the combo boxes.
My guess is maybe the delete code isn't firing the tableRowsRemoved event but I really don't know until I see some code. Try creating a Short Complete Example (Google it) and it might help work out what's wrong.
Hi, here is the delete code. It is supposed to remove the row from the model, but it seems it is just removing it from the GUI. An I thinks that's why it is throwing arrayIndexOutof Bounds exception - The array inside the combo box is all messed up. Am I missing something here?
as an aside, you should be using an actionListener for your button instead of a mouseListener,
it's no big deal, just consistency, but if you prefer mouseListener, note that mouseClicked
is definitely not the right choice, as it doesn't always fire. mousePressed is a far better choice.
to test mouseClicked, click and hold, move the mousePointer just a bit, now release. the event won't fire.
Thanks for the tip. I changed the mouseClicked to mousePressed and added that property to the table with no luck. I then tested that same property for the combo box, and to my wonder it accepted the property but it did not solve the problem.
> about the only thing left is to post a compilable/runnable program,
> so we can see exactly what's happening.
> just the bare bones,...
here's an interesting exercise for you:
copy the code you posted
now go to another pc, one with a java jdk,
but one that doesn't have netbeans, or have any of the micrm package classes
paste the code into notepad and try to compile via the command line
now you will be seeing what we see i.e. we can do nothing with the code you posted.
if you want a solution, you'll have to post something we can compile and run.