A combo box has two values: AND
and OR
.
I written property change listener for the Combo,as this event fires, if and only of the currently selected value and previous values are different. But I need that this event should be fired even if the values are same?
This is my sample code snippet:
public void setRuleOperation(String ruleOperation) {
String oldValue = this.ruleOperation;
if (oldValue != ruleOperation) {
this.ruleOperation = ruleOperation;
getPropertyChangeSupport().firePropertyChange(PROPERTY_OPERATION, oldValue, null);
}
this.ruleOperation = ruleOperation;
}
One possibility entails:
PropertyChangeEvent
instance using thePropertyChangeSupport
object.fire
method to emulatefirePropertyChange
.propertyChange
for each listener using the new event instance.Et la voilà, the
if
conditionals that prevent firing when the old value equals the new value have been skirted.This can be useful when firing multiple events for key presses using
PropertyChangeSupport
. Typing "Hello" would bubble up as "Helo" because the old key event ("l") matches the second key press event ("l"). Direct notification in this manner allows the double-"l" to bubble up two distinct key press/release events.