void (final KeyEvent e, final int delta) { int leadIndex = mySelectionModel.getLeadSelectionIndex(); int newLeadIndex = leadIndex + delta; if (newLeadIndex >= 0 && newLeadIndex < getCellCount()) { if ((e.getModifiers() & KeyEvent.SHIFT_MASK) != 0) { mySelectionModel.setSelectionInterval(mySelectionModel.getAnchorSelectionIndex(), newLeadIndex); } else { mySelectionModel.setSelectionInterval(newLeadIndex, newLeadIndex); } } }