JTable table = new JTable(); table.clearSelection();
JTable table = new JTable(); int[] selectedRows = table.getSelectedRows(); for (int i = 0; i < selectedRows.length; i++) { table.removeRowSelectionInterval(selectedRows[i], selectedRows[i]); }In this example, a new JTable instance is created and the getSelectedRows() method is used to retrieve an array of the currently selected rows. The for loop then iterates over the selected rows and calls the removeRowSelectionInterval() method to deselect each selected row. These examples use the javax.swing package library.