void (KeyEvent e) { int d; if (e.getKeyCode() == KeyEvent.VK_DOWN) { d = 1; } else if (e.getKeyCode() == KeyEvent.VK_UP) { d = -1; } else { return; } int row = myResultList.getSelectionModel().getLeadSelectionRow(); row += d; if (row >=0 && row < myResultList.getRowCount()) { myResultList.setSelectionRow(row); } }