private void removeLines(DocumentEvent e)
    {
        //  The root Element of the Document will tell us the total number
        //  of line in the Document.

        Document document = e.getDocument();
        Element root = document.getDefaultRootElement();

        while (root.getElementCount() > maximumLines)
        {
            if (isRemoveFromStart)
            {
                removeFromStart(document, root);
            }
            else
            {
                removeFromEnd(document, root);
            }
        }
    }