PTable extends JBTable implements DataProvider, DeleteProvider, CutProvider, CopyProvider, PasteProvider { public void restoreSelection(int previousSelectedRow, @Nullable PTableItem previousSelectedItem) { int selectedRow = 0; if (previousSelectedItem != null) { PTableItem item = previousSelectedRow >= 0 && previousSelectedRow < getRowCount() ? (PTableItem)getValueAt(previousSelectedRow, 0) : null; if (Objects.equals(item, previousSelectedItem)) { selectedRow = previousSelectedRow; } else { for (int row = 0; row < getRowCount(); row++) { item = (PTableItem)getValueAt(row, 0); if (item.equals(previousSelectedItem)) { selectedRow = row; break; } } } } if (selectedRow < getRowCount()) { addRowSelectionInterval(selectedRow, selectedRow); } } PTable(@NotNull PTableModel model);  PTable(@NotNull PTableModel model, @NotNull CopyPasteManager copyPasteManager); @Override void setModel(@NotNull TableModel model); @Override PTableModel getModel(); void setRendererProvider(@NotNull PTableCellRendererProvider rendererProvider); void setEditorProvider(PTableCellEditorProvider editorProvider); @Override boolean surrendersFocusOnKeyStroke(); @Override Component prepareEditor(TableCellEditor editor, int row, int column); @Override TableCellRenderer getCellRenderer(int row, int column); @Override PTableCellEditor getCellEditor(int row, int column); boolean isHover(int row, int col); @NotNull Point getHoverPosition(); @Override void setUI(TableUI ui); void restoreSelection(int previousSelectedRow, @Nullable PTableItem previousSelectedItem); @Nullable PTableItem getSelectedItem(); @Nullable PTableItem getItemAt(int rowIndex); @Override Object getData(@NotNull @NonNls String dataId); @Override boolean isCopyEnabled(@NotNull DataContext dataContext); @Override boolean isCopyVisible(@NotNull DataContext dataContext); @Override void performCopy(@NotNull DataContext dataContext); @Override boolean isCutEnabled(@NotNull DataContext dataContext); @Override boolean isCutVisible(@NotNull DataContext dataContext); @Override void performCut(@NotNull DataContext dataContext); @Override boolean canDeleteElement(@NotNull DataContext dataContext); @Override void deleteElement(@NotNull DataContext dataContext); @Override boolean isPastePossible(@NotNull DataContext dataContext); @Override boolean isPasteEnabled(@NotNull DataContext dataContext); @Override void performPaste(@NotNull DataContext dataContext);  }
@Test public void testRestoreSelection() { assertThat(myTable.getSelectedItem()).isNull(); myTable.restoreSelection(1, myEmptyItem); assertThat(myTable.getSelectedItem()).isSameAs(myEmptyItem); }