Comment supprimer les lignes sélectionnées d'un JTable?

J'ai essayé ceci:

public void removeSelectedFromTable(JTable from)
{
    int[] rows = from.getSelectedRows();
    TableModel tm= from.getModel();

    while(rows.length>0)
    {
        ((DefaultTableModel)tm).removeRow(from.convertRowIndexToModel(rows[0]));

        rows = from.getSelectedRows();
    }
    from.clearSelection();
}

Mais il arrive parfois qu'il laisse toujours là. Quel peut être le problème?

source d'informationauteur Penchant