com.jmex.bui.text
Class IntegerDocument

java.lang.Object
  extended by com.jmex.bui.text.Document
      extended by com.jmex.bui.text.IntegerDocument

public class IntegerDocument
extends Document

A document for use with a BTextField that allows only integer numeric input. Note: to allow fully valid values to be entered one character at a time, partially valid values (like the string '-' at position zero) must be allowed. Thus one cannot rely on the integer document only ever containing valid integers.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.jmex.bui.text.Document
Document.Listener
 
Field Summary
protected  boolean _positive
          If true, only positive values are allowed.
 
Fields inherited from class com.jmex.bui.text.Document
_listeners, _text
 
Constructor Summary
IntegerDocument()
          Creates a new document that allows any integer value.
IntegerDocument(boolean positive)
          Creates a new integer document.
 
Method Summary
protected  boolean validateEdit(String oldText, String newText)
          Provides an opportunity for edits to be rejected before being applied to the document.
 
Methods inherited from class com.jmex.bui.text.Document
addListener, getLength, getText, getText, insert, notify, remove, removeListener, replace, setText
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_positive

protected boolean _positive
If true, only positive values are allowed.

Constructor Detail

IntegerDocument

public IntegerDocument()
Creates a new document that allows any integer value.


IntegerDocument

public IntegerDocument(boolean positive)
Creates a new integer document.

Parameters:
positive - if true, only accept positive values
Method Detail

validateEdit

protected boolean validateEdit(String oldText,
                               String newText)
Description copied from class: Document
Provides an opportunity for edits to be rejected before being applied to the document.

Overrides:
validateEdit in class Document
Returns:
true if the document should be configured with the specified new text, false if the old text should remain.


Copyright © 2008 Michael Bayne. All Rights Reserved.