author | rriggs |
Tue, 03 Jun 2014 11:18:03 -0400 | |
changeset 25122 | 1ecc464c69d2 |
parent 22574 | 7f8ce0c8c20a |
child 25154 | a4252397d312 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
22574
7f8ce0c8c20a
8032627: Add @SuppressWarnings("serial") to appropriate javax.swing classes
darcy
parents:
20458
diff
changeset
|
2 |
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package javax.swing.event; |
|
27 |
||
28 |
import java.util.EventObject; |
|
29 |
import javax.swing.*; |
|
30 |
||
31 |
||
32 |
/** |
|
33 |
* An event that characterizes a change in selection. The change is limited to a |
|
34 |
* a single inclusive interval. The selection of at least one index within the |
|
35 |
* range will have changed. A decent {@code ListSelectionModel} implementation |
|
36 |
* will keep the range as small as possible. {@code ListSelectionListeners} will |
|
37 |
* generally query the source of the event for the new selected status of each |
|
38 |
* potentially changed row. |
|
39 |
* <p> |
|
40 |
* <strong>Warning:</strong> |
|
41 |
* Serialized objects of this class will not be compatible with |
|
42 |
* future Swing releases. The current serialization support is |
|
43 |
* appropriate for short term storage or RMI between applications running |
|
44 |
* the same version of Swing. As of 1.4, support for long term storage |
|
20458 | 45 |
* of all JavaBeans™ |
2 | 46 |
* has been added to the <code>java.beans</code> package. |
47 |
* Please see {@link java.beans.XMLEncoder}. |
|
48 |
* |
|
49 |
* @author Hans Muller |
|
50 |
* @author Ray Ryan |
|
51 |
* @see ListSelectionModel |
|
52 |
*/ |
|
22574
7f8ce0c8c20a
8032627: Add @SuppressWarnings("serial") to appropriate javax.swing classes
darcy
parents:
20458
diff
changeset
|
53 |
@SuppressWarnings("serial") // Same-version serialization only |
2 | 54 |
public class ListSelectionEvent extends EventObject |
55 |
{ |
|
56 |
private int firstIndex; |
|
57 |
private int lastIndex; |
|
58 |
private boolean isAdjusting; |
|
59 |
||
60 |
/** |
|
61 |
* Represents a change in selection status between {@code firstIndex} and |
|
62 |
* {@code lastIndex}, inclusive. {@code firstIndex} is less than or equal to |
|
63 |
* {@code lastIndex}. The selection of at least one index within the range will |
|
64 |
* have changed. |
|
65 |
* |
|
66 |
* @param firstIndex the first index in the range, <= lastIndex |
|
67 |
* @param lastIndex the last index in the range, >= firstIndex |
|
68 |
* @param isAdjusting whether or not this is one in a series of |
|
69 |
* multiple events, where changes are still being made |
|
70 |
*/ |
|
71 |
public ListSelectionEvent(Object source, int firstIndex, int lastIndex, |
|
72 |
boolean isAdjusting) |
|
73 |
{ |
|
74 |
super(source); |
|
75 |
this.firstIndex = firstIndex; |
|
76 |
this.lastIndex = lastIndex; |
|
77 |
this.isAdjusting = isAdjusting; |
|
78 |
} |
|
79 |
||
80 |
/** |
|
81 |
* Returns the index of the first row whose selection may have changed. |
|
82 |
* {@code getFirstIndex() <= getLastIndex()} |
|
83 |
* |
|
84 |
* @return the first row whose selection value may have changed, |
|
85 |
* where zero is the first row |
|
86 |
*/ |
|
87 |
public int getFirstIndex() { return firstIndex; } |
|
88 |
||
89 |
/** |
|
90 |
* Returns the index of the last row whose selection may have changed. |
|
91 |
* {@code getLastIndex() >= getFirstIndex()} |
|
92 |
* |
|
93 |
* @return the last row whose selection value may have changed, |
|
94 |
* where zero is the first row |
|
95 |
*/ |
|
96 |
public int getLastIndex() { return lastIndex; } |
|
97 |
||
98 |
/** |
|
99 |
* Returns whether or not this is one in a series of multiple events, |
|
100 |
* where changes are still being made. See the documentation for |
|
101 |
* {@link javax.swing.ListSelectionModel#setValueIsAdjusting} for |
|
102 |
* more details on how this is used. |
|
103 |
* |
|
104 |
* @return {@code true} if this is one in a series of multiple events, |
|
105 |
* where changes are still being made |
|
106 |
*/ |
|
107 |
public boolean getValueIsAdjusting() { return isAdjusting; } |
|
108 |
||
109 |
/** |
|
110 |
* Returns a {@code String} that displays and identifies this |
|
111 |
* object's properties. |
|
112 |
* |
|
113 |
* @return a String representation of this object |
|
114 |
*/ |
|
115 |
public String toString() { |
|
116 |
String properties = |
|
117 |
" source=" + getSource() + |
|
118 |
" firstIndex= " + firstIndex + |
|
119 |
" lastIndex= " + lastIndex + |
|
120 |
" isAdjusting= " + isAdjusting + |
|
121 |
" "; |
|
122 |
return getClass().getName() + "[" + properties + "]"; |
|
123 |
} |
|
124 |
} |