所以我试图清除 jTable 中的一行数据,但是当我到达最后一行并清除它时,它会清除......但给我一个错误“行索引超出范围”需要帮助:D
//Get table model.
DefaultTableModel model = (DefaultTableModel) tblStock.getModel();
//Create variable.
int selectedProduct = tblStock.getSelectedRow();
//Remove selected row.
model.removeRow(selectedProduct);
//Clear selection.
tblStock.clearSelection();
//Set intervals.
tblStock.setRowSelectionInterval(0, 0);
tblStock.setRowSelectionInterval(selectedProduct, selectedProduct);
}