com.levigo.util.swing.text
Class NumericDocument

java.lang.Object
  extended by javax.swing.text.AbstractDocument
      extended by javax.swing.text.PlainDocument
          extended by com.levigo.util.swing.text.NumericDocument
All Implemented Interfaces:
Serializable, Document

public class NumericDocument
extends PlainDocument

A plain Document, which allows only numerical input in a defined range.

Author:
Carolin Köhler
See Also:
NumericDocument(int, int), 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
 
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
NumericDocument(int min, int max)
          Constructor
 
Method Summary
 int getIntegerValue()
          Returns the actual value of the document
 int getMaximumValue()
           
 int getMinimumValue()
           
 void insertString(int offs, String str, AttributeSet a)
           
 boolean isCheckingEnabled()
          Returns a flag indicating if range check is active
 int parse(String proposedResult)
          Analyses given result string and returns its value.
 void remove(int offs, int len)
           
 void setCheckingEnabled(boolean checkingEnabled)
          Sets a flag indicating if range check is active
 
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
 

Constructor Detail

NumericDocument

public NumericDocument(int min,
                       int max)
Constructor

Parameters:
min - minimal value of the document
max - maximal value of the document
Method Detail

getIntegerValue

public int getIntegerValue()
Returns the actual value of the document

Returns:
int

insertString

public void insertString(int offs,
                         String str,
                         AttributeSet a)
                  throws BadLocationException
Specified by:
insertString in interface Document
Overrides:
insertString in class PlainDocument
Throws:
BadLocationException
See Also:
Document.insertString(int, java.lang.String, javax.swing.text.AttributeSet)

remove

public void remove(int offs,
                   int len)
            throws BadLocationException
Specified by:
remove in interface Document
Overrides:
remove in class AbstractDocument
Throws:
BadLocationException
See Also:
Document.remove(int, int)

parse

public int parse(String proposedResult)
          throws NumberFormatException
Analyses given result string and returns its value. If it can not convert to an integer or it is not in the defined range, a NumberformatException will be thrown.

Parameters:
proposedResult -
Returns:
int
Throws:
NumberFormatException

isCheckingEnabled

public boolean isCheckingEnabled()
Returns a flag indicating if range check is active

Returns:
boolean

setCheckingEnabled

public void setCheckingEnabled(boolean checkingEnabled)
Sets a flag indicating if range check is active

Parameters:
checkingEnabled - The checkingEnabled to set

getMaximumValue

public int getMaximumValue()

getMinimumValue

public int getMinimumValue()


Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.