@Override public void performAction(ActionEvent e) { Doc activeDoc = actionContext.get(ActionContextKeys.ACTIVE_DOC); Buffer buffer = activeDoc.getActiveBuffer(); int position = buffer.getInsertionPoint().getPosition(); Interval selection = buffer.getSelection(); if (selection != null) { position = selection.getEnd(); } buffer.getFinder().forward(position); }