public abstract class AbstractTextComponentValidator extends java.lang.Object implements java.awt.event.ActionListener, java.awt.event.FocusListener, javax.swing.event.DocumentListener, java.beans.PropertyChangeListener
validate()
. validate()
is invoked whenever
DocumentListener
)FocusListener
)JosmTextField
and an ActionEvent
is detectedModifier and Type | Field and Description |
---|---|
private static java.awt.Color |
ERROR_BACKGROUND |
private static javax.swing.border.Border |
ERROR_BORDER |
private java.lang.String |
msg |
private javax.swing.text.JTextComponent |
tc |
private java.lang.Boolean |
valid
remembers whether the content of the text component is currently valid or not; null means,
we don't know yet
|
Constructor and Description |
---|
AbstractTextComponentValidator(javax.swing.text.JTextComponent tc)
Creates the validator and weires it to the text component
tc . |
AbstractTextComponentValidator(javax.swing.text.JTextComponent tc,
boolean addActionListener)
Alternative constructor that allows to turn off the actionListener.
|
AbstractTextComponentValidator(javax.swing.text.JTextComponent tc,
boolean addFocusListener,
boolean addDocumentListener,
boolean addActionListener)
Constructs a new
AbstractTextComponentValidator . |
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent arg0) |
void |
changedUpdate(javax.swing.event.DocumentEvent arg0) |
protected void |
feedbackDisabled() |
protected void |
feedbackInvalid(java.lang.String msg) |
protected void |
feedbackValid(java.lang.String msg) |
void |
focusGained(java.awt.event.FocusEvent arg0) |
void |
focusLost(java.awt.event.FocusEvent arg0) |
javax.swing.text.JTextComponent |
getComponent()
Replies the decorated text component
|
void |
insertUpdate(javax.swing.event.DocumentEvent arg0) |
abstract boolean |
isValid()
Replies true if the current content of the decorated text component is valid;
false otherwise
|
void |
propertyChange(java.beans.PropertyChangeEvent evt) |
void |
removeUpdate(javax.swing.event.DocumentEvent arg0) |
abstract void |
validate()
Implement in subclasses to validate the content of the text component.
|
private static final javax.swing.border.Border ERROR_BORDER
private static final java.awt.Color ERROR_BACKGROUND
private javax.swing.text.JTextComponent tc
private java.lang.Boolean valid
private java.lang.String msg
public AbstractTextComponentValidator(javax.swing.text.JTextComponent tc)
tc
.tc
- the text component. Must not be null.java.lang.IllegalArgumentException
- if tc is nullpublic AbstractTextComponentValidator(javax.swing.text.JTextComponent tc, boolean addActionListener)
tc
- text componentaddActionListener
- true
to add the action listenerpublic AbstractTextComponentValidator(javax.swing.text.JTextComponent tc, boolean addFocusListener, boolean addDocumentListener, boolean addActionListener)
AbstractTextComponentValidator
.tc
- text componentaddFocusListener
- true
to add the focus listeneraddDocumentListener
- true
to add the document listeneraddActionListener
- true
to add the action listenerprotected void feedbackInvalid(java.lang.String msg)
protected void feedbackDisabled()
protected void feedbackValid(java.lang.String msg)
public javax.swing.text.JTextComponent getComponent()
public abstract void validate()
public abstract boolean isValid()
public void focusGained(java.awt.event.FocusEvent arg0)
focusGained
in interface java.awt.event.FocusListener
public void focusLost(java.awt.event.FocusEvent arg0)
focusLost
in interface java.awt.event.FocusListener
public void actionPerformed(java.awt.event.ActionEvent arg0)
actionPerformed
in interface java.awt.event.ActionListener
public void changedUpdate(javax.swing.event.DocumentEvent arg0)
changedUpdate
in interface javax.swing.event.DocumentListener
public void insertUpdate(javax.swing.event.DocumentEvent arg0)
insertUpdate
in interface javax.swing.event.DocumentListener
public void removeUpdate(javax.swing.event.DocumentEvent arg0)
removeUpdate
in interface javax.swing.event.DocumentListener
public void propertyChange(java.beans.PropertyChangeEvent evt)
propertyChange
in interface java.beans.PropertyChangeListener