public boolean setCurrentPageIndex(int pageIndex) {

        if (documentViewModel == null) {
            return false;
        }

        boolean changed;
        // make sure that new index is a valid choice.
        if (pageIndex < 0) {
            pageIndex = 0;
        } else if (pageIndex > document.getNumberOfPages() - 1) {
            pageIndex = document.getNumberOfPages() - 1;
        }
        int oldPageIndex = documentViewModel.getViewCurrentPageIndex();
        changed = documentViewModel.setViewCurrentPageIndex(pageIndex);

        if (documentView != null) {
            documentView.updateDocumentView();
        }

        // get location of page in view port
        Rectangle perferedPageOffset = documentViewModel.getPageBounds(getCurrentPageIndex());
        if (perferedPageOffset != null) {
            // scroll the view port to the correct location
            Rectangle currentViewSize = documentView.getBounds();

            // check to see of the perferedPageOffset will actually be possible.  If the
            // pages is smaller then the view port we need to correct x,y coordinates.
            if (perferedPageOffset.x + perferedPageOffset.width >
                    currentViewSize.width) {
                perferedPageOffset.x = currentViewSize.width - perferedPageOffset.width;
            }

            if (perferedPageOffset.y + perferedPageOffset.height >
                    currentViewSize.height) {
                perferedPageOffset.y = currentViewSize.height - perferedPageOffset.height;
            }

            documentViewScrollPane.getViewport().setViewPosition(perferedPageOffset.getLocation());
            documentViewScrollPane.revalidate();
        }
        firePropertyChange(PropertyConstants.DOCUMENT_CURRENT_PAGE,
                oldPageIndex, pageIndex);

        return changed;
    }