void () { super.hidePopup(); if (!myFilteringMode) return; Cell prev = UIUtil.getClientProperty(myComponent, SELECTION_BEFORE_KEY); int viewRow = myComponent.getSelectedRow(); // will be -1 if there is no matching elements (not filtered by rowFilter) if (viewRow > -1) { // keep selection as is } else if (prev != null && prev.row > -1 && prev.row < myComponent.getRowCount()) { int col = Math.min(prev.column, myComponent.getColumnCount()); myComponent.setRowSelectionInterval(prev.row, prev.row); myComponent.setColumnSelectionInterval(col, col); } else if (myComponent.getRowCount() > 0) { myComponent.setRowSelectionInterval(0, 0); myComponent.setColumnSelectionInterval(0, 0); } TableUtil.scrollSelectionToVisible(myComponent); }