qflib 0.98.1

de.qfs.lib.gui
Class LimitedDocument

java.lang.Object
  |
  +--javax.swing.text.AbstractDocument
        |
        +--javax.swing.text.PlainDocument
              |
              +--de.qfs.lib.gui.LimitedDocument
All Implemented Interfaces:
javax.swing.text.Document, java.io.Serializable

public class LimitedDocument
extends javax.swing.text.PlainDocument

An extension of PlainDocument that limits the number of characters the Document may hold.

Version:
$Revision: 1.6 $
Author:
Gregor Schmid
See Also:
Serialized Form

Inner classes inherited from class javax.swing.text.AbstractDocument
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
 
Fields inherited from class javax.swing.text.PlainDocument
lineLimitAttribute, tabSizeAttribute
 
Fields inherited from class javax.swing.text.AbstractDocument
BAD_LOCATION, BidiElementName, ContentElementName, ElementNameAttribute, listenerList, ParagraphElementName, SectionElementName
 
Fields inherited from interface javax.swing.text.Document
StreamDescriptionProperty, TitleProperty
 
Constructor Summary
LimitedDocument()
          Create a new LimitedDocument.
 
Method Summary
 void insertString(int offs, java.lang.String str, javax.swing.text.AttributeSet a)
          Insert a string into the document.
 void setLimit(int limit)
          Set the limit for the number of characters.
 
Methods inherited from class javax.swing.text.PlainDocument
createDefaultRoot, getDefaultRootElement, getParagraphElement, insertUpdate, removeUpdate
 
Methods inherited from class javax.swing.text.AbstractDocument
addDocumentListener, addUndoableEditListener, createBranchElement, createLeafElement, createPosition, dump, fireChangedUpdate, fireInsertUpdate, fireRemoveUpdate, fireUndoableEditUpdate, getAsynchronousLoadPriority, getAttributeContext, getBidiRootElement, getContent, getCurrentWriter, getDocumentProperties, getEndPosition, getLength, getListeners, getProperty, getRootElements, getStartPosition, getText, getText, postRemoveUpdate, putProperty, readLock, readUnlock, remove, removeDocumentListener, removeUndoableEditListener, render, setAsynchronousLoadPriority, setDocumentProperties, writeLock, writeUnlock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LimitedDocument

public LimitedDocument()
Create a new LimitedDocument.
Method Detail

setLimit

public void setLimit(int limit)
Set the limit for the number of characters.
Parameters:
limit - The limit to set.

insertString

public void insertString(int offs,
                         java.lang.String str,
                         javax.swing.text.AttributeSet a)
                  throws javax.swing.text.BadLocationException
Insert a string into the document. Only adds as much of string as will fit without exceeding the document's size limit.
Overrides:
insertString in class javax.swing.text.AbstractDocument
Parameters:
offs - The offset to insert at.
str - The string to insert.
a - The string's attributes.
Throws:
javax.swing.text.BadLocationException - If the offset is illegal for the document.

qflib 0.98.1