1. /*
  2. * @(#)DocumentListener.java 1.14 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.swing.event;
  8. import java.util.EventListener;
  9. /**
  10. * Interface for an observer to register to receive notifications
  11. * of changes to a text document.
  12. * <p>
  13. * The default implementation of
  14. * the Document interface (AbstractDocument) supports asynchronous
  15. * mutations. If this feature is used (i.e. mutations are made
  16. * from a thread other than the Swing event thread), the listeners
  17. * will be notified via the mutating thread. <em>This means that
  18. * if asynchronous updates are made, the implementation of this
  19. * interface must be threadsafe</em>!
  20. * <p>
  21. * The DocumentEvent notification is based upon the JavaBeans
  22. * event model. There is no guarantee about the order of delivery
  23. * to listeners, and all listeners must be notified prior to making
  24. * further mutations to the Document. <em>This means implementations
  25. * of the DocumentListener may not mutate the source of the event
  26. * (i.e. the associated Document)</em>.
  27. *
  28. * @author Timothy Prinzing
  29. * @version 1.14 12/19/03
  30. * @see javax.swing.text.Document
  31. * @see javax.swing.text.StyledDocument
  32. * @see DocumentEvent
  33. */
  34. public interface DocumentListener extends EventListener {
  35. /**
  36. * Gives notification that there was an insert into the document. The
  37. * range given by the DocumentEvent bounds the freshly inserted region.
  38. *
  39. * @param e the document event
  40. */
  41. public void insertUpdate(DocumentEvent e);
  42. /**
  43. * Gives notification that a portion of the document has been
  44. * removed. The range is given in terms of what the view last
  45. * saw (that is, before updating sticky positions).
  46. *
  47. * @param e the document event
  48. */
  49. public void removeUpdate(DocumentEvent e);
  50. /**
  51. * Gives notification that an attribute or set of attributes changed.
  52. *
  53. * @param e the document event
  54. */
  55. public void changedUpdate(DocumentEvent e);
  56. }