KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > swing > event > ListSelectionEvent


1 /*
2  * @(#)ListSelectionEvent.java 1.20 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.swing.event;
9
10 import java.util.EventObject JavaDoc;
11 import javax.swing.*;
12
13
14 /**
15  * An event that characterizes a change in the current
16  * selection. The change is limited to a row interval.
17  * ListSelectionListeners will generally query the source of
18  * the event for the new selected status of each potentially
19  * changed row.
20  * <p>
21  * <strong>Warning:</strong>
22  * Serialized objects of this class will not be compatible with
23  * future Swing releases. The current serialization support is
24  * appropriate for short term storage or RMI between applications running
25  * the same version of Swing. As of 1.4, support for long term storage
26  * of all JavaBeans<sup><font size="-2">TM</font></sup>
27  * has been added to the <code>java.beans</code> package.
28  * Please see {@link java.beans.XMLEncoder}.
29  *
30  * @version 1.20 12/19/03
31  * @author Hans Muller
32  * @author Ray Ryan
33  * @see ListSelectionModel
34  */

35 public class ListSelectionEvent extends EventObject JavaDoc
36 {
37     private int firstIndex;
38     private int lastIndex;
39     private boolean isAdjusting;
40
41     /**
42      * Represents a change in selection status between <code>firstIndex</code>
43      * and <code>lastIndex</code> inclusive
44      * (</code>firstIndex</code> is less than or equal to
45      * <code>lastIndex</code>). At least one of the rows within the range will
46      * have changed, a good <code>ListSelectionModel</code> implementation will
47      * keep the range as small as possible.
48      *
49      * @param firstIndex the first index that changed
50      * @param lastIndex the last index that changed, lastIndex >= firstIndex
51      * @param isAdjusting an indication that this is one of rapid a series of events
52      */

53     public ListSelectionEvent(Object JavaDoc source, int firstIndex, int lastIndex,
54                   boolean isAdjusting)
55     {
56     super(source);
57     this.firstIndex = firstIndex;
58     this.lastIndex = lastIndex;
59     this.isAdjusting = isAdjusting;
60     }
61
62     /**
63      * Returns the index of the first row whose selection may have changed.
64      * @return the first row whose selection value may have changed,
65      * where zero is the first row
66      */

67     public int getFirstIndex() { return firstIndex; }
68
69     /**
70      * Returns the index of the last row whose selection may have changed.
71      * @return the last row whose selection value may have changed,
72      * where zero is the first row
73      */

74     public int getLastIndex() { return lastIndex; }
75
76     /**
77      * Returns true if this is one of multiple change events.
78      * @return true if this is one of a rapid series of events
79      */

80     public boolean getValueIsAdjusting() { return isAdjusting; }
81
82     /**
83      * Returns a string that displays and identifies this
84      * object's properties.
85      *
86      * @return a String representation of this object
87      */

88     public String JavaDoc toString() {
89     String JavaDoc properties =
90         " source=" + getSource() +
91             " firstIndex= " + firstIndex +
92             " lastIndex= " + lastIndex +
93         " isAdjusting= " + isAdjusting +
94             " ";
95         return getClass().getName() + "[" + properties + "]";
96     }
97 }
98
99
Popular Tags