void (ActionEvent e) { int selIndexBefore = getSelectedIndex(); defaultAction.actionPerformed(e); int selIndexCurrent = getSelectedIndex(); if ((selectNext && selIndexBefore < selIndexCurrent) || (!selectNext && selIndexBefore > selIndexCurrent)) return; if (selectNext) { if (selIndexCurrent == selIndexBefore + 1) selIndexCurrent++; if (selIndexCurrent < getModel().getSize() - 1) { setSelectedIndex(selIndexCurrent + 1); scrollRectToVisible(getCellBounds(selIndexCurrent + 1, selIndexCurrent + 1)); } } else { if (selIndexCurrent > 0) { setSelectedIndex(selIndexCurrent - 1); scrollRectToVisible(getCellBounds(selIndexCurrent - 1, selIndexCurrent - 1)); } } }