|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.util.gui.DocumentAdapter
public abstract class DocumentAdapter
a convenience implementation that makes it easier to implement
a DocumentListener if you want to perform a certain task in all cases.
All methods defined in the DocumentListener interface are implemented
here to call the one abstract method.
In addition, this method has special support for JFormattedTextField,
which allows to avoid the effects from this bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4888144
| Field Summary | |
|---|---|
protected Map<JFormattedTextField,Object> |
fieldValues
the fields in this map will be checked for their values by the filter to see whether the changes are merely caused by a focus gain/loss to avoid the effects caused by http://bugs.sun.com/bugdatabase/view_bug.do? |
| Fields inherited from interface com.antelmann.util.Filter |
|---|
EXCLUDE_ALL_FILTER, INCLUDE_ALL_FILTER |
| Constructor Summary | |
|---|---|
DocumentAdapter(boolean autoCommit,
JFormattedTextField... fields)
|
|
DocumentAdapter(JFormattedTextField... fields)
|
|
| Method Summary | |
|---|---|
boolean |
accept(DocumentEvent ev)
only accepts events that are to actually trigger documentUpdated(DocumentEvent). |
void |
add(JFormattedTextField field)
see fieldValues |
void |
changedUpdate(DocumentEvent ev)
|
abstract void |
documentUpdated(DocumentEvent ev)
only called when the event is accepted by accept(DocumentEvent) |
JFormattedTextField[] |
getFields()
|
void |
insertUpdate(DocumentEvent ev)
|
boolean |
isAutoCommit()
|
void |
remove(JFormattedTextField field)
|
void |
removeUpdate(DocumentEvent ev)
|
void |
setAutoCommit(boolean autoCommit)
allows to specify whether the filter method should call JFormattedTextField.commitEdit(),
so that when documentUpdated(DocumentEvent) is called, the getValue() method will
return the latest current value based on the text |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final Map<JFormattedTextField,Object> fieldValues
| Constructor Detail |
|---|
public DocumentAdapter(JFormattedTextField... fields)
public DocumentAdapter(boolean autoCommit,
JFormattedTextField... fields)
fields - see fieldValues| Method Detail |
|---|
public boolean isAutoCommit()
public void setAutoCommit(boolean autoCommit)
JFormattedTextField.commitEdit(),
so that when documentUpdated(DocumentEvent) is called, the getValue() method will
return the latest current value based on the text
public void add(JFormattedTextField field)
fieldValues
public void remove(JFormattedTextField field)
public JFormattedTextField[] getFields()
public abstract void documentUpdated(DocumentEvent ev)
accept(DocumentEvent)
public void insertUpdate(DocumentEvent ev)
insertUpdate in interface DocumentListenerpublic void removeUpdate(DocumentEvent ev)
removeUpdate in interface DocumentListenerpublic void changedUpdate(DocumentEvent ev)
changedUpdate in interface DocumentListenerpublic boolean accept(DocumentEvent ev)
documentUpdated(DocumentEvent).
This implementation also checks the fieldValues and returns false
if the value didn't actually change.
If setAutoCommit(boolean) is set to true, this method will commit each edit
directly, so that when implementing documentUpdated(DocumentEvent) you can
already rely on the committed value when calling JFormattedTextField.getValue().
Override this if you want a different behavior.
accept in interface Filter<DocumentEvent>fieldValues
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||