public void dispose() {

        disposing = true;
        if (isDirtyTimer != null)
            isDirtyTimer.stop();

        removeMouseListener(this);
        removeMouseMotionListener(this);
        removeComponentListener(this);

        // remove annotation listeners.
        removeMouseMotionListener(annotationHandler);
        removeMouseListener(annotationHandler);

        // text selection
        removeMouseMotionListener(textSelectionHandler);
        removeMouseListener(textSelectionHandler);

        // remove focus listener
        removeFocusListener(this);

        // remove repaint listener
        removePageRepaintListener();

        if (bufferedPageImageReference != null) {
            Image pageBufferImage = bufferedPageImageReference.get();
            if (pageBufferImage != null) {
                pageBufferImage.flush();
            }
        }

        inited = false;
    }