public void dispose() {
        if (disposed)
            return;
        disposed = true;

        closeDocument();

        openFileMenuItem = null;
        openURLMenuItem = null;
        closeMenuItem = null;
        saveAsFileMenuItem = null;
        exportTextMenuItem = null;
        exportSVGMenuItem = null;
        permissionsMenuItem = null;
        informationMenuItem = null;
        printSetupMenuItem = null;
        printMenuItem = null;
        exitMenuItem = null;

        fitActualSizeMenuItem = null;
        fitPageMenuItem = null;
        fitWidthMenuItem = null;
        zoomInMenuItem = null;
        zoomOutMenuItem = null;
        rotateLeftMenuItem = null;
        rotateRightMenuItem = null;
        showHideToolBarMenuItem = null;
        showHideUtilityPaneMenuItem = null;

        firstPageMenuItem = null;
        previousPageMenuItem = null;
        nextPageMenuItem = null;
        lastPageMenuItem = null;
        searchMenuItem = null;
        goToPageMenuItem = null;

        minimiseAllMenuItem = null;
        bringAllToFrontMenuItem = null;
        windowListMenuItems = null;

        aboutMenuItem = null;

        openFileButton = null;
        saveAsFileButton = null;
        printButton = null;
        searchButton = null;
        showHideUtilityPaneButton = null;

        firstPageButton = null;
        previousPageButton = null;
        nextPageButton = null;
        lastPageButton = null;
        if (currentPageNumberTextField != null) {
            currentPageNumberTextField.removeActionListener(this);
            currentPageNumberTextField.removeFocusListener(this);
            currentPageNumberTextField.removeKeyListener(this);
            currentPageNumberTextField = null;
        }
        numberOfPagesLabel = null;

        zoomInButton = null;
        zoomOutButton = null;
        if (zoomComboBox != null) {
            zoomComboBox.removeItemListener(this);
            zoomComboBox = null;
        }

        fitActualSizeButton = null;
        fitHeightButton = null;
        fitWidthButton = null;

        rotateLeftButton = null;
        rotateRightButton = null;

        panToolButton = null;
        zoomInToolButton = null;
        zoomOutToolButton = null;
        textSelectToolButton = null;
        selectToolButton = null;
        linkAnnotationToolButton = null;

        fontEngineButton = null;

        completeToolBar = null;

        outlinesTree = null;
        if (outlinesScrollPane != null) {
            outlinesScrollPane.removeAll();
            outlinesScrollPane = null;
        }
        if (searchPanel != null) {
            searchPanel.dispose();
            searchPanel = null;
        }
        if (thumbnailsPanel != null) {
            thumbnailsPanel.dispose();
            thumbnailsPanel = null;
        }
        if (utilityTabbedPane != null) {
            utilityTabbedPane.removeAll();
            utilityTabbedPane = null;
        }

        // Clean up the document view controller
        if (documentViewController != null) {
            documentViewController.dispose();
        }

        // clean up search controller
        if (documentSearchController != null) {
            documentSearchController.dispose();
        }

        if (utilityAndDocumentSplitPane != null) {
            utilityAndDocumentSplitPane.removeAll();
            utilityAndDocumentSplitPane.removePropertyChangeListener(this);
        }

        statusLabel = null;
        if (viewer != null) {
            viewer.removeWindowListener(this);
            viewer.removeAll();
        }
        viewModel = null;

        windowManagementCallback = null;
    }