'JTable - removeRow works, but it does not update the table

I have a button that will remove a selected row from the table with the use of the removeRow method from DefaultTableModel. The problem is, it does not update the table but it does remove the row. I know it because when I spam the delete button, it will give me an error of:

java.lang.ArrayIndexOutOfBoundsException: 0 >= 0

Here is my code for deleting the row:

public void deleteRows(){
    int selectedRow = deletePanel.table.getSelectedRow();
    DefaultTableModel tb = (DefaultTableModel) deletePanel.table.getModel();
    tb.removeRow(selectedRow);
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source