public class LengthLimitingDocument extends PlainDocument
AbstractDocument.AbstractElement, AbstractDocument.AttributeContext, AbstractDocument.BranchElement, AbstractDocument.Content, AbstractDocument.DefaultDocumentEvent, AbstractDocument.ElementEdit, AbstractDocument.LeafElement
lineLimitAttribute, tabSizeAttribute
BidiElementName, ContentElementName, ElementNameAttribute, ParagraphElementName, SectionElementName
StreamDescriptionProperty, TitleProperty
Constructor and Description |
---|
LengthLimitingDocument()
Creates a new LengthLimitingDocument, with no limitation.
|
LengthLimitingDocument(int maxlen)
Creates a new LengthLimitingDocument with the given limitation.
|
Modifier and Type | Method and Description |
---|---|
int |
getMaxLength()
Returns the defined maximum number characters for this document.
|
void |
insertString(int offs,
String str,
AttributeSet a)
Inserts the string into the document.
|
void |
setMaxLength(int maxlen)
Sets the maximum number of characters for this document.
|
getDefaultRootElement, getParagraphElement
addDocumentListener, addUndoableEditListener, createPosition, dump, getAsynchronousLoadPriority, getBidiRootElement, getDocumentFilter, getDocumentListeners, getDocumentProperties, getEndPosition, getLength, getListeners, getProperty, getRootElements, getStartPosition, getText, getText, getUndoableEditListeners, putProperty, readLock, readUnlock, remove, removeDocumentListener, removeUndoableEditListener, render, replace, setAsynchronousLoadPriority, setDocumentFilter, setDocumentProperties
public LengthLimitingDocument()
public LengthLimitingDocument(int maxlen)
maxlen
- the maximum number of elements in this documentpublic void setMaxLength(int maxlen)
maxlen
- the maximum number of characters in this document.public int getMaxLength()
public void insertString(int offs, String str, AttributeSet a) throws BadLocationException
insertString
in interface Document
insertString
in class PlainDocument
offs
- the offset, where the string should be inserted into the documentstr
- the string that should be inserteda
- the attribute set assigned for the documentBadLocationException
- if the offset is not correct