org.jurvis.swing
Class JvReadOnlyPlainDocument

java.lang.Object
  extended by javax.swing.text.AbstractDocument
      extended by javax.swing.text.PlainDocument
          extended by org.jurvis.swing.JvReadOnlyPlainDocument
All Implemented Interfaces:
Serializable, Document

public class JvReadOnlyPlainDocument
extends PlainDocument

A PlainDocument that does not allow the user to make edits. Frequently, when using a JTextField to display always non-editable text, using this document is preferable to making the JTextComponent non-editable.

Author:
Neil W. Weber
See Also:
JvReadOnlyTextField, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.text.AbstractDocument
AbstractDocument.AbstractElement, AbstractDocument.AttributeContext, AbstractDocument.BranchElement, AbstractDocument.Content, AbstractDocument.DefaultDocumentEvent, AbstractDocument.ElementEdit, AbstractDocument.LeafElement
 
Field Summary
static JvReadOnlyPlainDocument EMPTY_DOCUMENT
           
 
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
JvReadOnlyPlainDocument()
          Constructs a plain, empty text document.
JvReadOnlyPlainDocument(String s)
          Constructs a plain text document with the given string.
 
Method Summary
 void insertString(int offs, String str, AttributeSet a)
          Inserts some content into the document.
 void remove(int offs, int len)
          Removes a portion of the content of the document.
 
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, getDocumentFilter, getDocumentListeners, getDocumentProperties, getEndPosition, getLength, getListeners, getProperty, getRootElements, getStartPosition, getText, getText, getUndoableEditListeners, postRemoveUpdate, putProperty, readLock, readUnlock, removeDocumentListener, removeUndoableEditListener, render, replace, setAsynchronousLoadPriority, setDocumentFilter, setDocumentProperties, writeLock, writeUnlock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_DOCUMENT

public static final JvReadOnlyPlainDocument EMPTY_DOCUMENT
Constructor Detail

JvReadOnlyPlainDocument

public JvReadOnlyPlainDocument()
Constructs a plain, empty text document.


JvReadOnlyPlainDocument

public JvReadOnlyPlainDocument(String s)
Constructs a plain text document with the given string.

Parameters:
s - the string to represent
Method Detail

insertString

public void insertString(int offs,
                         String str,
                         AttributeSet a)
                  throws BadLocationException
Inserts some content into the document. Actually, in this class this method simply discards the new content and does nothing.

Specified by:
insertString in interface Document
Overrides:
insertString in class PlainDocument
Parameters:
offs - the starting offset >= 0
str - the string to insert; does nothing with null/empty strings
a - the attributes for the inserted content
Throws:
BadLocationException - the given insert position is not a valid position within the document
See Also:
Document.insertString(int, java.lang.String, javax.swing.text.AttributeSet)

remove

public void remove(int offs,
                   int len)
            throws BadLocationException
Removes a portion of the content of the document. Actually, in this class this method just ignores the removal and does nothing.

Specified by:
remove in interface Document
Overrides:
remove in class AbstractDocument
Parameters:
offs - the offset from the beginning >= 0
len - the number of characters to remove >= 0
Throws:
BadLocationException - some portion of the removal range was not a valid part of the document. The location in the exception is the first bad position encountered.


Copyright © 1999-2004 Neil W. Weber. All Rights Reserved.