KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > swing > text > html > TextAreaDocument


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
9 import javax.swing.text.*;
10
11
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.8 12/19/03
20  */

21   
22 class TextAreaDocument extends PlainDocument {
23
24     String JavaDoc initialText;
25   
26
27     /**
28      * Resets the model by removing all the data,
29      * and restoring it to its initial state.
30      */

31     void reset() {
32     try {
33         remove(0, getLength());
34         if (initialText != null) {
35         insertString(0, initialText, null);
36         }
37     } catch (BadLocationException e) {
38     }
39     }
40
41     /**
42      * Stores the data that the model is initially
43      * loaded with.
44      */

45     void storeInitialText() {
46     try {
47         initialText = getText(0, getLength());
48     } catch (BadLocationException e) {
49     }
50     }
51 }
52
53
54
55
56
Popular Tags