
package uk.co.wingpath.event;

import java.util.*;

/**
* An event that indicates that a value has changed, or is changing.
* <p>Although this event is normally only generated when a value has actually
* changed, this is not guaranteed. The event may sometimes be generated
* when a new value is set that is equal to the old value.
* <p>A "changing" event is currently only generated when the user is editing
* a text field, and has not yet pressed Enter or permanently moved the focus
* elsewhere.
* <p>This event should only be fired on the AWT event dispatch thread, and
* ValueListeners may assume that the <code>valueChanged</code> method is called
* from that thread.
* @see ValueListener
* @see ValueEventSource
*/

public class ValueEvent
    extends EventObject
{
    private final boolean changing;

    /**
    * Constructs a ValueEvent.
    * @param source source of the event.
    * @param changing whether the value is changing.
    */
    public ValueEvent (Object source, boolean changing)
    {
        super (source);
        this.changing = changing;
    }

    /**
    * Constructs a non-changing ValueEvent.
    * @param source source of the event.
    */
    public ValueEvent (Object source)
    {
        this (source, false);
    }

    /**
    * Returns the <code>changing</code> flag.
    * @return the <code>changing</code> flag.
    */
    public boolean isChanging ()
    {
        return changing;
    }
}

