0
所以即時嘗試清除jTable中的一行數據,但是當我到達最後一行並清除它時,它會清除......但給我一個錯誤「行索引超出範圍「需要幫助請:d從jTable清除數據行
//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);
}