Re: ArrayIndexOutOfBounds Exception in DefaultTableModel

From: Andrew McDonagh (news_at_andrewcdonagh.f2s.com)
Date: 01/04/05


Date: Tue, 04 Jan 2005 08:44:17 +0000

Rohan Chaudhari via JavaKB.com wrote:
> Hi,
>

snipped exception...

> Code for clearing the table results:
>
> public void removeAll()
> {
> int rows = getRowCount();
> for (int i = 0; i < rows; i++)
> removeRow(0);
> }

................../\

you are always removing row 0 - i think you meant to remove row(i);

>
> I found that : if I select a row other than the first one and try to remove a row using removeRow(0), a valueChanged() event of DefaultListSelectionModel is getting fired. However, this event is not getting fired when I select the first row and then remove the row.
>
> If anybody has any idea about this, kindly help me understand this behaviour.
>
> Thanking you in anticipation
>