removing selected rows from Jtable

this is my code but it does not work it removes only the first selected rowpublic void isSelected(){for(int pos=0;pos<=KnihaModel.getRowCount();pos++){if(tbKniha.isRowSelected(pos))KnihaModel.remove(pos);}
[250 byte] By [Dedeka] at [2007-11-27 8:01:44]
# 1

I use this method of removing selected rows from a JTable:

int[] selectedRows = getSelectedRows();

if ( selectedRows.length != 0 )

{

for ( int i = 0; i < selectedRows.length; i++ )

{

int selectedRow = selectedRows[ i ] - i;

removeRow( selectedRow );

}

}

Because every time you remove a row, the next selected row will be one less then the previous.

Make sense?

bryanoa at 2007-7-12 19:43:50 > top of Java-index,Desktop,Core GUI APIs...
# 2
thx it works fine
Dedeka at 2007-7-12 19:43:50 > top of Java-index,Desktop,Core GUI APIs...