@Override public void actionPerformed(ActionEvent e) { MarkupSource source = panel.getSelectedSource(); final boolean hasPreviousItem = source.hasPreviousItem(); final boolean hasPreviousPage = source.hasPreviousPage(); int indexVal = 0; if (hasPreviousItem || hasPreviousPage) { if (!hasPreviousItem) { // flip the page previousPage(); indexVal = source.currentItem(); } else { indexVal = source.previousItem(); } // scroll panel.scrollToAnchor(source.getAnchorPrefix() + Integer.toString(indexVal)); // update display panel.updateCurrentMatchDisplay(source.currentItem()); panel.updateTotaMatcheslDisplay(source.getNumberHits()); // update controls if needed if (!source.hasPreviousItem() && !source.hasPreviousPage()) { panel.enablePrevMatchControl(false); } if (source.hasNextItem() || source.hasNextPage()) { panel.enableNextMatchControl(true); } } }