|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.InputVerifier
org.brains2b.swingext.mask.NumberValidator
public class NumberValidator
NumberValidator is an InputValidator that functions like a display mask for numbers.
for example: if you typed 50 using the default mask the displayed value would be 50,00
if you typed 1000,1 using the default mask the displayed value would be 1.000,10
You can set the mask the input will comply to through the Constructor
If the mask is not supplied the default "##.###9,99" is used.
Constructor Summary | |
---|---|
NumberValidator()
Constructor for NumberValidator. |
|
NumberValidator(java.lang.String mask)
Constructor for NumberValidator. |
|
NumberValidator(java.lang.String mask,
java.util.Locale locale)
|
Method Summary | |
---|---|
java.lang.String |
getErrorMessage()
retrieves the errormessage if verify returns false. |
java.lang.String |
getLocalizedMessage()
retrieve the error message, localized to the default locale if verify returns false |
java.lang.String |
getString(java.lang.String txt)
gets a String as representation of the value from a InputValidator Implementations might differ on what you need the value for. |
java.lang.String |
getString(java.lang.String txt,
java.lang.Class c)
gets a String as representation of the value from a InputValidator Implemenations differ for the implementations of this interface and on which Class is supplied for output. |
java.lang.String |
makeString(java.lang.String txt)
makes a masked String for a number that is represented without a decimal place but does have one in the mask. |
boolean |
verify(javax.swing.JComponent input)
Just a reference to verify in javax.swing.InputVerifier |
Methods inherited from class javax.swing.InputVerifier |
---|
shouldYieldFocus |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public NumberValidator()
Uses the default mask "##.##9,99"
public NumberValidator(java.lang.String mask)
mask
- String, the mask to be used to display numbers
(see class description for mask characters)public NumberValidator(java.lang.String mask, java.util.Locale locale)
Method Detail |
---|
public boolean verify(javax.swing.JComponent input)
InputValidator
verify
in interface InputValidator
verify
in class javax.swing.InputVerifier
InputVerifier.verify(JComponent)
public java.lang.String getErrorMessage()
InputValidator
getErrorMessage
in interface InputValidator
InputValidator.getErrorMessage()
public java.lang.String getString(java.lang.String txt)
InputValidator
Implementations might differ on what you need the value for.
If you can do with the value with the Mask just use the getText() on which ever field this InputValidator is implemented on.
getString
in interface InputValidator
txt
- String, the Masked text of this Validator
InputValidator.getString(String)
public java.lang.String getString(java.lang.String txt, java.lang.Class c)
InputValidator
Implemenations differ for the implementations of this interface and on which Class is supplied for output. Also not all requested output Classes are implemented for every implementation. on which ever field this InputValidator is implemented on.
getString
in interface InputValidator
txt
- String, the Masked text of this Validatorc
- Class, the type of output you want to return as a String representation
public java.lang.String makeString(java.lang.String txt)
Assumed is that the value is multiplied with 10^x, where x is the position from the right of the decimal place.
txt
- String, the text that should represent a number
public java.lang.String getLocalizedMessage()
InputValidator
getLocalizedMessage
in interface InputValidator
InputValidator.getLocalizedMessage()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |