public class LengthLimitingDocument extends javax.swing.text.PlainDocument
javax.swing.text.AbstractDocument.AbstractElement, javax.swing.text.AbstractDocument.AttributeContext, javax.swing.text.AbstractDocument.BranchElement, javax.swing.text.AbstractDocument.Content, javax.swing.text.AbstractDocument.DefaultDocumentEvent, javax.swing.text.AbstractDocument.ElementEdit, javax.swing.text.AbstractDocument.LeafElement
Constructor | Description |
---|---|
LengthLimitingDocument() |
Creates a new LengthLimitingDocument, with no limitation.
|
LengthLimitingDocument(int maxlen) |
Creates a new LengthLimitingDocument with the given limitation.
|
Modifier and Type | Method | Description |
---|---|---|
int |
getMaxLength() |
Returns the defined maximum number characters for this document.
|
void |
insertString(int offs,
java.lang.String str,
javax.swing.text.AttributeSet a) |
Inserts the string into the document.
|
void |
setMaxLength(int maxlen) |
Sets the maximum number of characters for this document.
|
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, writeUnlock
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, java.lang.String str, javax.swing.text.AttributeSet a) throws javax.swing.text.BadLocationException
insertString
in class javax.swing.text.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 documentjavax.swing.text.BadLocationException
- if the offset is not correct