I create DocumentListeners like so:
MyDocumentListener dl = new MyDocumentListener();
tab.getDocument().addDocumentListener( dl );
MyDocumentListener is a class that provides the event handling. However, I want to remove the DocumentListener but I do not know how to reference the MyDocumentListener object that I created.
The short answer is: you need to store the MyDocumentListener object that you created someplace you can access it. I don't know the structure of your code, so I cannot say what is the best location to save it. If you want to immediately remove the document listener you just added, just do:
MyDocumentListener dl = new MyDocumentListener();
tab.getDocument().addDocumentListener( dl );
tab.getDocument().removeDocumentListener( dl );
...but that's probably not what you want (why would you remove the document listener you just added?) So, consider editing the question with more details about the structure of your software, so perhaps then answerers can propose locations where to store the DocumentListener you created.