|
ehsbe CommonsTM Version 1.1.0rc3 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.text.JTextComponent
javax.swing.JTextField
javax.swing.JFormattedTextField
com.ehsbe.commons.gui.JxTextNumberField
public class JxTextNumberField
A textfield, which allows locale specific number characters only and restricts the number to certain size/precision.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.JFormattedTextField |
|---|
JFormattedTextField.AbstractFormatter, JFormattedTextField.AbstractFormatterFactory |
| Nested classes/interfaces inherited from class javax.swing.JTextField |
|---|
JTextField.AccessibleJTextField |
| Nested classes/interfaces inherited from class javax.swing.text.JTextComponent |
|---|
JTextComponent.AccessibleJTextComponent, JTextComponent.DropLocation, JTextComponent.KeyBinding |
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
JComponent.AccessibleJComponent |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary |
|---|
| Fields inherited from class javax.swing.JFormattedTextField |
|---|
COMMIT, COMMIT_OR_REVERT, PERSIST, REVERT |
| Fields inherited from class javax.swing.JTextField |
|---|
notifyAction |
| Fields inherited from class javax.swing.text.JTextComponent |
|---|
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY |
| Fields inherited from class javax.swing.JComponent |
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface javax.swing.SwingConstants |
|---|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
JxTextNumberField()
Default constructor, which uses a precision of 15 and a scale of 4 and the default locale. |
|
JxTextNumberField(Class<?> entityClass,
String methodName)
Construct an text field for the given entity with the default locale. |
|
JxTextNumberField(Class<?> entityClass,
String methodName,
Locale locale)
Construct an text field for the given entity. |
|
JxTextNumberField(int precision,
int scale,
Locale locale)
Construct an text field for the given entity. |
|
| Method Summary | |
|---|---|
String |
getDefaultTooltipText()
Get the default tooltip for this component. |
NumberFormat |
getNumberFormat()
Get the NumberFormatter used by this component. |
String |
getToolTipText()
Get the tootltip for this component. |
Validator<Number> |
getValidator()
Get the Validator used to check, whether the fields input is valid. |
Number |
getValue()
|
protected void |
processFocusEvent(FocusEvent e)
|
void |
setLocale(Locale l)
|
void |
setMinimumDigits(int intDigits,
int floatDigits)
Set the minimum number of digits, which should be used by the formatter. |
void |
setTemplate(Class<?> entityClass,
String methodName)
Set the number formatter and validator wrt. the given entity class and method. |
void |
setToolTipText(String text)
|
void |
setValidator(Validator<Number> validator)
Set the Validator used to check, whether the fields input is valid. |
void |
setValue(Object value)
|
protected void |
validate(Number num)
If a validator is set, this method validates the input and decorates the component, which used this component in a setLabelFor
method. |
| Methods inherited from class javax.swing.JFormattedTextField |
|---|
commitEdit, getActions, getFocusLostBehavior, getFormatter, getFormatterFactory, getUIClassID, invalidEdit, isEditValid, processInputMethodEvent, setDocument, setFocusLostBehavior, setFormatter, setFormatterFactory |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public JxTextNumberField()
public JxTextNumberField(Class<?> entityClass,
String methodName,
Locale locale)
entityClass - entity classmethodName - name of the method, which should be used to
obtain the Column.scale() and
Column.precision() for the fieldlocale - locale to use for obtaining valid number characters.
If null, default locale will be used to construct a
formatter.setTemplate(Class, String)
public JxTextNumberField(int precision,
int scale,
Locale locale)
precision - number of digits excl. the floating point and
possible leading sign character, i.e. number of digits on the left
plus number of digits on the right side of the floating point.scale - digits after (i.e. on the right side of) the floating pointlocale - locale to use for obtaining valid number characters
public JxTextNumberField(Class<?> entityClass,
String methodName)
entityClass - entity classmethodName - name of the method, which should be used to
obtain the Column.scale() and
Column.precision() for the field| Method Detail |
|---|
public void setTemplate(Class<?> entityClass,
String methodName)
If the given entity or method is null or the given method
of the entity could not be found, a default precision of
15 and scale of 4 is used.
If the given entity and method has been found but extracted precision and
scale are both 0 or no anotation was found at all, a default precision of
11 and scale of 0 is used.
Furthermore precision values of 0 are replaced with
15.
A scale of 0 forces Integer formatting style (i.e.
fraction point and digits are stripped).
entityClass - entity classmethodName - name of the method, which should be used to
obtain the Column.scale() and
Column.precision() for the fieldpublic void setLocale(Locale l)
setLocale in class Component
public void setMinimumDigits(int intDigits,
int floatDigits)
intDigits - number of integer digits before a possible floating
point sign.floatDigits - number of digits after the floating point sign.public NumberFormat getNumberFormat()
public Number getValue()
getValue in class JFormattedTextFieldpublic void setValue(Object value)
setValue in class JFormattedTextFieldprotected void validate(Number num)
setLabelFor
method.
num - number to validatepublic String getToolTipText()
If tooltip is set to an empty String, this component tries to obtain the
Tooltip from its corresponding label.
If it is still null an empty string and there is a template set,
which restricts the format, the number format message is returned.
getToolTipText in class JComponentgetDefaultTooltipText()public void setToolTipText(String text)
setToolTipText in class JComponentpublic String getDefaultTooltipText()
protected void processFocusEvent(FocusEvent e)
processFocusEvent in class JFormattedTextFieldpublic Validator<Number> getValidator()
Per default a validator gets automatically installed, if the @Column's
nullable property is set to false. It accepts
numbers, only.
null if not set, the validator otherwise.public void setValidator(Validator<Number> validator)
validator - null to disable validation, the validator
otherwise.
|
ehsbe CommonsTM Version 1.1.0rc3 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||