diff options
Diffstat (limited to 'libjava/classpath/javax/swing/event/ListDataEvent.java')
-rw-r--r-- | libjava/classpath/javax/swing/event/ListDataEvent.java | 60 |
1 files changed, 47 insertions, 13 deletions
diff --git a/libjava/classpath/javax/swing/event/ListDataEvent.java b/libjava/classpath/javax/swing/event/ListDataEvent.java index 2a6e6dbe9f0..897fc128f20 100644 --- a/libjava/classpath/javax/swing/event/ListDataEvent.java +++ b/libjava/classpath/javax/swing/event/ListDataEvent.java @@ -1,5 +1,5 @@ /* ListDataEvent.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -41,6 +41,9 @@ package javax.swing.event; import java.util.EventObject; /** + * An event that contains information about a modification to the content of + * a list. + * * @author Andrew Selkirk * @author Ronald Veldema */ @@ -48,32 +51,46 @@ public class ListDataEvent extends EventObject { private static final long serialVersionUID = 2510353260071004774L; + /** An event type indicating that the list content has been modified. */ public static final int CONTENTS_CHANGED = 0; + + /** An event type indicating that an interval has been added to the list. */ public static final int INTERVAL_ADDED = 1; + + /** + * An event type indicating that an interval has been removed from the + * list. + */ public static final int INTERVAL_REMOVED = 2; - private int type = 0; - private int index0 = 0; - private int index1 = 0; + private int type; + private int index0; + private int index1; /** * Creates a <code>ListDataEvent</code> object. * - * @param source The source of the event. - * @param type The type of the event - * @param index0 Bottom of range - * @param index1 Top of range + * @param source the source of the event (<code>null</code> not permitted). + * @param type the type of the event (should be one of + * {@link #CONTENTS_CHANGED}, {@link #INTERVAL_ADDED} or + * {@link #INTERVAL_REMOVED}, although this is not enforced). + * @param index0 the index for one end of the modified range of list + * elements. + * @param index1 the index for the other end of the modified range of list + * elements. */ public ListDataEvent(Object source, int type, int index0, int index1) { super(source); this.type = type; - this.index0 = index0; - this.index1 = index1; + this.index0 = Math.min(index0, index1); + this.index1 = Math.max(index0, index1); } /** - * Returns the bottom index. + * Returns the index of the first item in the range of modified list items. + * + * @return The index of the first item in the range of modified list items. */ public int getIndex0() { @@ -81,7 +98,9 @@ public class ListDataEvent extends EventObject } /** - * Returns the top index. + * Returns the index of the last item in the range of modified list items. + * + * @return The index of the last item in the range of modified list items. */ public int getIndex1() { @@ -89,10 +108,25 @@ public class ListDataEvent extends EventObject } /** - * Returns the type of this event. + * Returns a code representing the type of this event, which is usually one + * of {@link #CONTENTS_CHANGED}, {@link #INTERVAL_ADDED} or + * {@link #INTERVAL_REMOVED}. + * + * @return The event type. */ public int getType() { return type; } + + /** + * Returns a string representing the state of this event. + * + * @return A string. + */ + public String toString() + { + return getClass().getName() + "[type=" + type + ",index0=" + index0 + + ",index1=" + index1 + "]"; + } } |