private void reflectPageChangeInComponents() {
        boolean opened = document != null;
        int nPages = (getPageTree() != null) ? getPageTree().getNumberOfPages() : 0;
        int currentPage = isCurrentPage() ?
                documentViewController.getCurrentPageDisplayValue() : 0;

        setEnabled(firstPageMenuItem, opened && currentPage != 1);
        setEnabled(previousPageMenuItem, opened && currentPage != 1);
        setEnabled(nextPageMenuItem, opened && currentPage != nPages);
        setEnabled(lastPageMenuItem, opened && currentPage != nPages);

        setEnabled(firstPageButton, opened && currentPage != 1);
        setEnabled(previousPageButton, opened && currentPage != 1);
        setEnabled(nextPageButton, opened && currentPage != nPages);
        setEnabled(lastPageButton, opened && currentPage != nPages);

        if (currentPageNumberTextField != null) {
            currentPageNumberTextField.setText(
                    opened ? Integer.toString(currentPage) : "");
        }
    }