com.myjavaworld.gui
Class SingleLineDocument
java.lang.Object
javax.swing.text.AbstractDocument
javax.swing.text.PlainDocument
com.myjavaworld.gui.MPlainDocument
com.myjavaworld.gui.SingleLineDocument
- All Implemented Interfaces:
- Serializable, Document
public class SingleLineDocument
- extends MPlainDocument
An extension of PlainDocument
that allows only one line of text
in the document at any given time. The purpose of this class is to use it
with JTextField
and its extensions so that they will not allow
multiple lines of text. For E.g. The javax.swing.JTextField
does not work quite well when multiple lines of text is pasted in to
it.
- Version:
- 1.0
- Author:
- Sai Pullabhotla, psai [at] jMethods [dot] com
- See Also:
- Serialized Form
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, remove, 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 |
SingleLineDocument
public SingleLineDocument()
- Default Constructor.
insertString
public void insertString(int offset,
String str,
AttributeSet a)
throws BadLocationException
- Inserts the given string,
str
at the given position,
offset
. The implementation of this method ignores all the
text that appears after a new line character ( \r
or
\n
).
- Specified by:
insertString
in interface Document
- Overrides:
insertString
in class MPlainDocument
- Throws:
BadLocationException
Copyright © 2000-2012 jMethods, Inc.. All Rights Reserved.