1. /*
  2. * @(#)TextAreaDocument.java 1.8 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.text.html;
  8. import javax.swing.text.*;
  9. /**
  10. * TextAreaDocument extends the capabilities of the PlainDocument
  11. * to store the data that is initially set in the Document.
  12. * This is stored in order to enable an accurate reset of the
  13. * state when a reset is requested.
  14. *
  15. * @author Sunita Mani
  16. * @version 1.8 12/19/03
  17. */
  18. class TextAreaDocument extends PlainDocument {
  19. String initialText;
  20. /**
  21. * Resets the model by removing all the data,
  22. * and restoring it to its initial state.
  23. */
  24. void reset() {
  25. try {
  26. remove(0, getLength());
  27. if (initialText != null) {
  28. insertString(0, initialText, null);
  29. }
  30. } catch (BadLocationException e) {
  31. }
  32. }
  33. /**
  34. * Stores the data that the model is initially
  35. * loaded with.
  36. */
  37. void storeInitialText() {
  38. try {
  39. initialText = getText(0, getLength());
  40. } catch (BadLocationException e) {
  41. }
  42. }
  43. }