org.gjt.btools.ext
Class NonNegativeIntegerDocument

java.lang.Object
  |
  +--javax.swing.text.AbstractDocument
        |
        +--javax.swing.text.PlainDocument
              |
              +--org.gjt.btools.ext.NonNegativeIntegerDocument
All Implemented Interfaces:
javax.swing.text.Document, java.io.Serializable

public class NonNegativeIntegerDocument
extends javax.swing.text.PlainDocument

A document class used to enter a non-negative integer into a text component. This class ensures that the input contains only digits.

See Also:
Serialized Form

Field Summary
 
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
NonNegativeIntegerDocument()
           
 
Method Summary
 int getIntValue()
          Returns the integer value stored in the document as an int.
 long getLongValue()
          Returns the integer value stored in the document as a long.
 void insertString(int offs, java.lang.String str, javax.swing.text.AttributeSet a)
          Attempts to insert a string into 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, 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
 

Constructor Detail

NonNegativeIntegerDocument

public NonNegativeIntegerDocument()
Method Detail

insertString

public void insertString(int offs,
                         java.lang.String str,
                         javax.swing.text.AttributeSet a)
                  throws javax.swing.text.BadLocationException
Attempts to insert a string into the document.

Specified by:
insertString in interface javax.swing.text.Document
Overrides:
insertString in class javax.swing.text.PlainDocument
javax.swing.text.BadLocationException

getIntValue

public int getIntValue()
Returns the integer value stored in the document as an int.

Returns:
the non-negative integer stored, or -1 if the document is empty.

getLongValue

public long getLongValue()
Returns the integer value stored in the document as a long.

Returns:
the non-negative integer stored, or -1 if the document is empty.


Copyright © 1998-2001, Ben Burton
This software is released under the GNU Public License.
For further information, or to submit a bug or other problem, please contact Ben Burton (bab@debian.org).