com.jgoodies.binding.beans
public abstract class DelayedPropertyChangeHandler extends java.lang.Object implements java.beans.PropertyChangeListener
If this handler is notified about a property change it stores
the PropertyChangeEvent it has received in #propertyChange
,
and starts a Swing Timer that will call #delayedPropertyChange
after a delay. In coalescing mode a previously started timer - if any -
will be stopped before. In other words, the timer is restarted.
TODO: Write about the recommended delay time - above the double-click time and somewhere below a second, e.g. 100ms to 200ms.
TODO: Summarize the differences between the DelayedReadValueModel, the DelayedWriteValueModel, and this DelayedPropertyChangeHandler.
DelayedReadValueModel
,
DelayedWriteValueModel
,
Timer
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_DELAY
The delay in milliseconds used as default in the no-arg constructor.
|
Constructor and Description |
---|
DelayedPropertyChangeHandler()
Constructs a DelayedPropertyChangeHandler with a default delay.
|
DelayedPropertyChangeHandler(int delay)
Constructs a DelayedPropertyChangeHandler with the specified Timer delay
and the coalesce disabled.
|
DelayedPropertyChangeHandler(int delay,
boolean coalesce)
Constructs a DelayedPropertyChangeHandler with the specified Timer delay
and the given coalesce mode.
|
Modifier and Type | Method and Description |
---|---|
abstract void |
delayedPropertyChange(java.beans.PropertyChangeEvent evt)
This method gets called after this handler's delay
if a bound property has changed.
|
int |
getDelay()
Returns the delay, in milliseconds, that is used to defer value change
notifications.
|
boolean |
isCoalesce()
Returns if this model coalesces all pending changes or not.
|
boolean |
isPending()
Checks and answers whether there are pending events.
|
void |
propertyChange(java.beans.PropertyChangeEvent evt)
This handler has been notified about a change in a bound property.
|
void |
setCoalesce(boolean b)
Sets if this model shall coalesce all pending changes or not.
|
void |
setDelay(int delay)
Sets the delay, in milliseconds, that is used to defer value change
notifications.
|
void |
stop()
Stops a running timer.
|
public static final int DEFAULT_DELAY
public DelayedPropertyChangeHandler()
public DelayedPropertyChangeHandler(int delay)
delay
- the milliseconds to wait before the delayed property change
will be performedjava.lang.IllegalArgumentException
- if the delay is negativepublic DelayedPropertyChangeHandler(int delay, boolean coalesce)
delay
- the milliseconds to wait before the delayed property change
will be performedcoalesce
- true
to coalesce all pending changes,
false
to fire changes with the delay when an update
has been receivedjava.lang.IllegalArgumentException
- if the delay is negativesetCoalesce(boolean)
public final int getDelay()
setDelay(int)
public final void setDelay(int delay)
delay
- the delay, in milliseconds, that is used to defer
value change notificationsjava.lang.IllegalArgumentException
- if the delay is negativegetDelay()
public final boolean isCoalesce()
true
if all pending changes will be coalesced,
false
if pending changes are fired with a delay
when an update has been received.setCoalesce(boolean)
public final void setCoalesce(boolean b)
false
, a change event will be fired
with this model's delay when an update has been received.
The default value is false
.
Note that this value is not the #coalesce value of this model's internal Swing timer.
b
- true
to coalesce,
false
to fire separate changespublic final void stop()
#delayedPropertyChange
.public final boolean isPending()
true
if there are pending events, false
if not.public final void propertyChange(java.beans.PropertyChangeEvent evt)
#delayedPropertyChange
after this handler's delay.
If coalescing is enabled, a previously started timer - if any -
if stopped before. In other words, the timer is restarted.propertyChange
in interface java.beans.PropertyChangeListener
evt
- the PropertyChangeEvent describing the event source
and the property that has changedpublic abstract void delayedPropertyChange(java.beans.PropertyChangeEvent evt)
#propertyChange
.evt
- the PropertyChangeEvent describing the event source
and the property that has changedCopyright © 2002-2010 JGoodies Karsten Lentzsch. All Rights Reserved.