edu.northwestern.at.utils.swing.notepad
Class Notepad.MyDocumentListener

java.lang.Object
  extended by edu.northwestern.at.utils.swing.CustomDocumentListener
      extended by edu.northwestern.at.utils.swing.notepad.Notepad.MyDocumentListener
All Implemented Interfaces:
java.util.EventListener, javax.swing.event.DocumentListener
Enclosing class:
Notepad

protected class Notepad.MyDocumentListener
extends CustomDocumentListener

Listens for changes to document being edited.


Constructor Summary
protected Notepad.MyDocumentListener()
           
 
Method Summary
protected  boolean isRealChange(javax.swing.event.DocumentEvent e)
          Check if event really does something.
 
Methods inherited from class edu.northwestern.at.utils.swing.CustomDocumentListener
changedUpdate, insertUpdate, removeUpdate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Notepad.MyDocumentListener

protected Notepad.MyDocumentListener()
Method Detail

isRealChange

protected boolean isRealChange(javax.swing.event.DocumentEvent e)
Description copied from class: CustomDocumentListener
Check if event really does something.

Overrides:
isRealChange in class CustomDocumentListener
Parameters:
e - An event to check.
Returns:
True if event actually did something to the document.

For some reason, the document listener can get events saying something changed, but in fact these events record no real change to the document. To prevent the document from being marked dirty unnecessarily, we check the "toString()" of the event. A bogus event returns "[]" as its toString(), while a real event will have a much lengthier toString() with information about the nature of the change, what was changed, etc.