|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
kiwi.ui.DataField
An base class that implements basic functionality for a text field
that places constraints on its input.
DataField
validates its input when it loses or gains focus,
generates an action event, or when messaged with the
validateInput()
method. The no-op method
checkInput()
must be overloaded by subclassers to perform
the actual data validation.
Invalid input is flagged by repainting the contents of the field in red. If a key is typed into a field so highlighted, the text reverts back to black (non-flagged). Validation is not performed whenever the contents of the field change, as the necessary parsing is an expensive operation.
Inner Class Summary | |
private class |
DataField._DocumentListener
|
Field Summary | |
private boolean |
adjusting
|
private ChangeSupport |
csupport
|
private DataField._DocumentListener |
documentListener
|
private boolean |
inputRequired
|
protected boolean |
invalid
A state flag for representing validation state. |
Constructor Summary | |
DataField()
Construct a new DataField . |
|
DataField(int width)
Construct a new DataField with the specified width. |
Method Summary | |
private void |
_fireChange()
|
private void |
_init()
|
void |
addChangeListener(javax.swing.event.ChangeListener listener)
Add a ChangeListener to this component's list of listeners. |
protected boolean |
checkInput()
Determine if the given input is valid for this field. |
int |
getMaximumLength()
Get the maxmium number of characters that may be entered into this field. |
boolean |
isInputRequired()
Determine if input is required in this field. |
protected void |
paintInvalid(boolean invalid)
Paint the necessary decorations for the field to denote invalid (or valid) input. |
void |
removeChangeListener(javax.swing.event.ChangeListener listener)
Add a ChangeListener to this component's list of listeners. |
void |
setDocument(javax.swing.text.Document doc)
|
void |
setEditable(boolean flag)
Set the editable state of this field. |
void |
setInputRequired(boolean flag)
Specify whether an input is required in this field. |
void |
setMaximumLength(int length)
Set the maximum number of characters that may be entered into this field. |
void |
setText(java.lang.String text)
Set the text to be displayed by this field. |
boolean |
validateInput()
Validate the input in this field. |
Field Detail |
private ChangeSupport csupport
private DataField._DocumentListener documentListener
private boolean inputRequired
protected boolean invalid
private boolean adjusting
Constructor Detail |
public DataField()
DataField
.public DataField(int width)
DataField
with the specified width.Method Detail |
private void _init()
public void setDocument(javax.swing.text.Document doc)
public void addChangeListener(javax.swing.event.ChangeListener listener)
ChangeListener
to this component's list of listeners.
ChangeEvent
s are fired when this text field's document model
changes.listener
- The listener to add.public void removeChangeListener(javax.swing.event.ChangeListener listener)
ChangeListener
to this component's list of listeners.
ChangeEvent
s are fired when this text field's document model
changes.listener
- The listener to add.private void _fireChange()
public final void setText(java.lang.String text)
ChangeEvent
will not be fired when the data in the field is modified via this
call.text
- The text to set.protected void paintInvalid(boolean invalid)
invalid
- A flag specifying whether the input in the field is
currently valid or invalid.public void setEditable(boolean flag)
flag
- A flag specifying whether this field should be editable.
Non-editable fields are made transparent.public void setInputRequired(boolean flag)
validateInput()
method will return true
if the field is left empty; otherwise it will return false.flag
- The flag.validateInput()
,
isInputRequired()
public boolean isInputRequired()
public final boolean validateInput()
protected boolean checkInput()
public void setMaximumLength(int length)
KDocument
via a call to setDocument()
.length
- The new maximum length, or KDocument.NO_LIMIT
for unlimited length.kiwi.ui.model.KDocument
public int getMaximumLength()
KDocument.NO_LIMIT
if there
is no limit.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |