|
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
com.ehsbe.commons.gui.JxTextField
public class JxTextField
A JTextField, which checks the Column.length
definition of
the given entity class and method, to restrict the number of insertable
characters.
It also validates the field input of editable fields wrt. to the entities
nullable
annotated method, i.e. the coresponding label is set
to color red if validation fails.
DocumentSizeFilter
,
JLabel.setLabelFor(java.awt.Component)
,
Serialized FormNested Class Summary |
---|
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 | |
---|---|
static String |
LABEL_COLOR
property, which is used to remember the original foreground color of the text from an label. |
static String |
LABELED_BY_PROPERTY
property used by JLabel.setLabelFor(java.awt.Component) |
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 | |
---|---|
JxTextField()
Default constructor. |
|
JxTextField(Class<?> entityClass,
String methodName)
Construct an text field for the given entity and method. |
|
JxTextField(int maxLength,
boolean nullable)
Create a textfield with the given max. input length. |
Method Summary | |
---|---|
String |
getDefaultTooltipText()
Get the default tooltip for this component. |
int |
getMaxCharacters()
Get the max. number of characters allowed in this text field. |
String |
getText()
|
String |
getToolTipText()
Get the tootltip for this component. |
Validator<String> |
getValidator()
Get the Validator used to check, whether the fields input is valid. |
protected void |
processFocusEvent(FocusEvent e)
|
void |
setDocument(Document doc)
Same as JTextField.setDocument(javax.swing.text.Document) , but
sets a document size filter, if the corresponding entity has a size limit
and the given document is of type AbstractDocument . |
void |
setSelectOnFocus(boolean enable)
Set, whether the component should select all the available text, if it get the focus. |
void |
setTemplate(Class<?> entityClass,
String methodName)
Adjust the document size filter wrt. the given entity class and method. |
void |
setText(String t)
|
void |
setToolTipText(String text)
|
void |
setValidator(Validator<String> validator)
Set the Validator used to check, whether the fields input is valid. |
protected void |
validate(String txt)
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 java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String LABELED_BY_PROPERTY
JLabel.setLabelFor(java.awt.Component)
public static final String LABEL_COLOR
Constructor Detail |
---|
public JxTextField()
public JxTextField(int maxLength, boolean nullable)
maxLength
- max length of text, which might be entered.nullable
- if false
, an internal validator gets
assigned to the field, which makes sure, that only none-empty
values are excepted. Furthermore if validation fails and the
text filed contains a client property named
LABELED_BY_PROPERTY
, which contains a
JComponent
, the components foreground color
is set to the color stored in the textfield's property
LABEL_COLOR
or RED
if not set.public JxTextField(Class<?> entityClass, String methodName)
entityClass
- entity classmethodName
- name of the method, which should be used to
obtain the Column.length()
for the fieldsetTemplate(Class, String)
Method Detail |
---|
public void setTemplate(Class<?> entityClass, String methodName)
If both parameters are null
or no
appropriate annotations are found, this method does nothing.
Otherwise it set a new Validator and if the underlying document is not
an AbstractDocument, it gets replaced with a new one as well.
entityClass
- entity classmethodName
- name of the method, which should be used to
obtain the Column.length()
for the fieldpublic String getText()
getText
in class JTextComponent
public void setText(String t)
setText
in class JTextComponent
protected void validate(String txt)
setLabelFor
method.
txt
- text to validatepublic int getMaxCharacters()
-1
if not limited, the max. number of characters
otherwisepublic void setDocument(Document doc)
JTextField.setDocument(javax.swing.text.Document)
, but
sets a document size filter, if the corresponding entity has a size limit
and the given document is of type AbstractDocument
.
setDocument
in class JTextField
doc
- @inheritDocpublic String getToolTipText()
If tooltip is set to an empty String, this component tries
to obtain the Tooltip from its corresponding label or more exactly from
the JComponent stored in this client property map with the key
LABELED_BY_PROPERTY.
If it is still null
or an empty string and there is a template
set, which restricts the number of characters in this document, the max
number of character message is returned.
getToolTipText
in class JComponent
getDefaultTooltipText()
public void setToolTipText(String text)
setToolTipText
in class JComponent
public String getDefaultTooltipText()
public Validator<String> getValidator()
Per default a validator gets automatically installed, if the @Column's
nullable
property is set to false. It accepts
none-whitespace/null values, only.
null
if not set, the validator otherwise.public void setValidator(Validator<String> validator)
validator
- null
to disable validation, the validator
otherwise.public void setSelectOnFocus(boolean enable)
enable
- if true
enable select all on focus gained.protected void processFocusEvent(FocusEvent e)
processFocusEvent
in class Component
|
ehsbe CommonsTM Version 1.1.0rc3 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |