public class Number_Document
extends javax.swing.text.PlainDocument
PlainDocument
that allows only those characters suitable for an
English decimal number. These include the ten digits, the decimal point
('.'), the comma (','), the plus sign ('+'), and
the minus sign ('-'). All other characters are ignored and never
become part of the Number_Document's content.
NOTE: No attempt is made to ensure that the contents of the document form a valid number. The document may read '..+++---,' for example, which is not a valid number but which contains only valid number characters.
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
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ID
Class identification name with source code version and date.
|
Constructor and Description |
---|
Number_Document()
Creates a new Number_Document using the
PlainDocument 's
default content container. |
Number_Document(javax.swing.text.AbstractDocument.Content container)
Creates a new Number_Document using the specified container for the
document's content.
|
Modifier and Type | Method and Description |
---|---|
void |
insertString(int offset,
java.lang.String str,
javax.swing.text.AttributeSet a)
Inserts content into the document.
|
createDefaultRoot, getDefaultRootElement, getParagraphElement, insertUpdate, removeUpdate
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 static final java.lang.String ID
public Number_Document()
PlainDocument
's
default content container.PlainDocument.PlainDocument()
public Number_Document(javax.swing.text.AbstractDocument.Content container)
container
- the document's content container.PlainDocument.PlainDocument(AbstractDocument.Content)
public void insertString(int offset, java.lang.String str, javax.swing.text.AttributeSet a) throws javax.swing.text.BadLocationException
insertString
in interface javax.swing.text.Document
insertString
in class javax.swing.text.PlainDocument
offset
- the starting offset, at least 0.str
- the string to insert; null/empty strings are not inserted.a
- the attributes for the inserted content; this document does not
use attributes.javax.swing.text.BadLocationException
PlainDocument.insertString(int, java.lang.String, javax.swing.text.AttributeSet)
Copyright \ (C) Arizona Board of Regents on behalf of the \ Planetary Image Research Laboratory, Lunar and \ Planetary Laboratory at the University of Arizona