com.levigo.util.swing.text
Class NumericDocument
java.lang.Object
javax.swing.text.AbstractDocument
javax.swing.text.PlainDocument
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
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 |
NumericDocument
public NumericDocument(int min,
int max)
- Constructor
- Parameters:
min
- minimal value of the documentmax
- maximal value of the document
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.