|
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.JTextArea
com.ehsbe.commons.gui.JxTextArea
public class JxTextArea
A JTextArea, 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.
Actually this is pure code duplication from JxTextField and could not be avoided because both are direct children of JTextComponent.
DocumentSizeFilter,
JLabel.setLabelFor(java.awt.Component),
Serialized Form| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.JTextArea |
|---|
JTextArea.AccessibleJTextArea |
| 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.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 java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
JxTextArea()
Default constructor. |
|
JxTextArea(Class<?> entityClass,
String methodName,
int rows,
int columns)
As long as no template is set, it behaves like a normal JTextArea, i.e. unrestricted content length. |
|
JxTextArea(int rows,
int columns)
As long as no template is set, it behaves like a normal JTextArea, i.e. unrestricted content length. |
|
JxTextArea(String text)
As long as no template is set, it behaves like a normal JTextArea, i.e. unrestricted content length. |
|
JxTextArea(String text,
int rows,
int columns)
As long as no template is set, it behaves like a normal JTextArea, i.e. unrestricted content length. |
|
JxTextArea(String text,
int rows,
int columns,
int maxLength,
boolean nullable)
Create a textarea 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()
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. |
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 JxTextArea()
public JxTextArea(String text)
text - text to insert into the area
public JxTextArea(int rows,
int columns)
rows - number of rows of the areacolumns - number of columns of the area
public JxTextArea(String text,
int rows,
int columns)
text - text to insert into the arearows - number of rows of the areacolumns - number of columns of the area
public JxTextArea(String text,
int rows,
int columns,
int maxLength,
boolean nullable)
text - text to insert into the arearows - number of rows of the areacolumns - number of columns of the areamaxLength - 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 JxTextArea(Class<?> entityClass,
String methodName,
int rows,
int columns)
entityClass - entity classmethodName - name of the method, which should be used to
obtain the Column.length() for the fieldrows - number of rows of the area. Use 0 for
default values.columns - number of columns of the area. Use 0 for
default values.setTemplate(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 JTextComponentpublic void setText(String t)
setText in class JTextComponentprotected 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 JTextComponentdoc - @inheritDocpublic String getToolTipText()
getToolTipText in class JComponentgetDefaultTooltipText()public void setToolTipText(String text)
setToolTipText in class JComponentpublic 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 | |||||||||