1. /*
  2. * @(#)TextAreaDocument.java 1.5 00/02/02
  3. *
  4. * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package javax.swing.text.html;
  11. import javax.swing.text.*;
  12. /**
  13. * TextAreaDocument extends the capabilities of the PlainDocument
  14. * to store the data that is initially set in the Document.
  15. * This is stored in order to enable an accurate reset of the
  16. * state when a reset is requested.
  17. *
  18. * @author Sunita Mani
  19. * @version 1.5 02/02/00
  20. */
  21. class TextAreaDocument extends PlainDocument {
  22. String initialText;
  23. /**
  24. * Resets the model by removing all the data,
  25. * and restoring it to its initial state.
  26. */
  27. void reset() {
  28. try {
  29. remove(0, getLength());
  30. if (initialText != null) {
  31. insertString(0, initialText, null);
  32. }
  33. } catch (BadLocationException e) {
  34. }
  35. }
  36. /**
  37. * Stores the data that the model is initially
  38. * loaded with.
  39. */
  40. void storeInitialText() {
  41. try {
  42. initialText = getText(0, getLength());
  43. } catch (BadLocationException e) {
  44. }
  45. }
  46. }