public class PlainDocument extends AbstractDocument
The default content storage management is performed by a gapped buffer implementation (GapContent). It supports editing reasonably large documents with good efficiency when the edits are contiguous or clustered, as is typical.
 Warning:
 Serialized objects of this class will not be compatible with
 future Swing releases. The current serialization support is
 appropriate for short term storage or RMI between applications running
 the same version of Swing.  As of 1.4, support for long term storage
 of all JavaBeansTM
 has been added to the java.beans package.
 Please see XMLEncoder.
Document, 
AbstractDocumentAbstractDocument.AbstractElement, AbstractDocument.AttributeContext, AbstractDocument.BranchElement, AbstractDocument.Content, AbstractDocument.DefaultDocumentEvent, AbstractDocument.ElementEdit, AbstractDocument.LeafElement| Modifier and Type | Field and Description | 
|---|---|
| static String | lineLimitAttributeName of the attribute that specifies the maximum
 length of a line, if there is a maximum length. | 
| static String | tabSizeAttributeName of the attribute that specifies the tab
 size for tabs contained in the content. | 
BAD_LOCATION, BidiElementName, ContentElementName, ElementNameAttribute, listenerList, ParagraphElementName, SectionElementNameStreamDescriptionProperty, TitleProperty| Constructor and Description | 
|---|
| PlainDocument()Constructs a plain text document. | 
| PlainDocument(AbstractDocument.Content c)Constructs a plain text document. | 
| Modifier and Type | Method and Description | 
|---|---|
| protected AbstractDocument.AbstractElement | createDefaultRoot()Creates the root element to be used to represent the
 default document structure. | 
| Element | getDefaultRootElement()Gets the default root element for the document model. | 
| Element | getParagraphElement(int pos)Get the paragraph element containing the given position. | 
| void | insertString(int offs,
            String str,
            AttributeSet a)Inserts some content into the document. | 
| protected void | insertUpdate(AbstractDocument.DefaultDocumentEvent chng,
            AttributeSet attr)Updates document structure as a result of text insertion. | 
| protected void | removeUpdate(AbstractDocument.DefaultDocumentEvent chng)Updates any document structure as a result of text removal. | 
addDocumentListener, addUndoableEditListener, createBranchElement, createLeafElement, createPosition, dump, fireChangedUpdate, fireInsertUpdate, fireRemoveUpdate, fireUndoableEditUpdate, getAsynchronousLoadPriority, getAttributeContext, getBidiRootElement, getContent, getCurrentWriter, getDocumentFilter, getDocumentListeners, getDocumentProperties, getEndPosition, getLength, getListeners, getProperty, getRootElements, getStartPosition, getText, getText, getUndoableEditListeners, postRemoveUpdate, putProperty, readLock, readUnlock, remove, removeDocumentListener, removeUndoableEditListener, render, replace, setAsynchronousLoadPriority, setDocumentFilter, setDocumentProperties, writeLock, writeUnlockpublic static final String tabSizeAttribute
public static final String lineLimitAttribute
public PlainDocument()
GapContent is constructed and set.public PlainDocument(AbstractDocument.Content c)
c - the container for the contentpublic void insertString(int offs,
                String str,
                AttributeSet a)
                  throws BadLocationException
This method is thread safe, although most Swing methods are not. Please see How to Use Threads for more information.
insertString in interface DocumentinsertString in class AbstractDocumentoffs - the starting offset >= 0str - the string to insert; does nothing with null/empty stringsa - the attributes for the inserted contentBadLocationException - the given insert position is not a valid
   position within the documentDocument.insertString(int, java.lang.String, javax.swing.text.AttributeSet)public Element getDefaultRootElement()
getDefaultRootElement in interface DocumentgetDefaultRootElement in class AbstractDocumentDocument.getDefaultRootElement()protected AbstractDocument.AbstractElement createDefaultRoot()
public Element getParagraphElement(int pos)
getParagraphElement in class AbstractDocumentpos - the starting offset >= 0protected void insertUpdate(AbstractDocument.DefaultDocumentEvent chng, AttributeSet attr)
insertUpdate in class AbstractDocumentchng - the change event describing the ditattr - the set of attributes for the inserted textprotected void removeUpdate(AbstractDocument.DefaultDocumentEvent chng)
removeUpdate in class AbstractDocumentchng - the change event describing the edit Submit a bug or feature 
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
 Copyright © 1993, 2011, Oracle and/or its affiliates.  All rights reserved.