author | rriggs |
Tue, 03 Jun 2014 11:18:03 -0400 | |
changeset 25122 | 1ecc464c69d2 |
parent 23010 | 6dadb192ad81 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
23010
6dadb192ad81
8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents:
20458
diff
changeset
|
2 |
* Copyright (c) 1997, 2013, 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 |
||
30 |
||
31 |
/** |
|
32 |
* Defines an event that encapsulates changes to a list. |
|
33 |
* <p> |
|
34 |
* <strong>Warning:</strong> |
|
35 |
* Serialized objects of this class will not be compatible with |
|
36 |
* future Swing releases. The current serialization support is |
|
37 |
* appropriate for short term storage or RMI between applications running |
|
38 |
* the same version of Swing. As of 1.4, support for long term storage |
|
20458 | 39 |
* of all JavaBeans™ |
2 | 40 |
* has been added to the <code>java.beans</code> package. |
41 |
* Please see {@link java.beans.XMLEncoder}. |
|
42 |
* |
|
43 |
* @author Hans Muller |
|
44 |
*/ |
|
11268 | 45 |
@SuppressWarnings("serial") |
2 | 46 |
public class ListDataEvent extends EventObject |
47 |
{ |
|
48 |
/** Identifies one or more changes in the lists contents. */ |
|
49 |
public static final int CONTENTS_CHANGED = 0; |
|
50 |
/** Identifies the addition of one or more contiguous items to the list */ |
|
51 |
public static final int INTERVAL_ADDED = 1; |
|
52 |
/** Identifies the removal of one or more contiguous items from the list */ |
|
53 |
public static final int INTERVAL_REMOVED = 2; |
|
54 |
||
55 |
private int type; |
|
56 |
private int index0; |
|
57 |
private int index1; |
|
58 |
||
59 |
/** |
|
60 |
* Returns the event type. The possible values are: |
|
61 |
* <ul> |
|
62 |
* <li> {@link #CONTENTS_CHANGED} |
|
63 |
* <li> {@link #INTERVAL_ADDED} |
|
64 |
* <li> {@link #INTERVAL_REMOVED} |
|
65 |
* </ul> |
|
66 |
* |
|
67 |
* @return an int representing the type value |
|
68 |
*/ |
|
69 |
public int getType() { return type; } |
|
70 |
||
71 |
/** |
|
72 |
* Returns the lower index of the range. For a single |
|
73 |
* element, this value is the same as that returned by {@link #getIndex1}. |
|
74 |
||
75 |
* |
|
76 |
* @return an int representing the lower index value |
|
77 |
*/ |
|
78 |
public int getIndex0() { return index0; } |
|
79 |
/** |
|
80 |
* Returns the upper index of the range. For a single |
|
81 |
* element, this value is the same as that returned by {@link #getIndex0}. |
|
82 |
* |
|
83 |
* @return an int representing the upper index value |
|
84 |
*/ |
|
85 |
public int getIndex1() { return index1; } |
|
86 |
||
87 |
/** |
|
20428
929cd48fca8a
8025249: [javadoc] fix some javadoc errors in javax/swing/
yan
parents:
11268
diff
changeset
|
88 |
* Constructs a ListDataEvent object. If index0 is > |
2 | 89 |
* index1, index0 and index1 will be swapped such that |
20428
929cd48fca8a
8025249: [javadoc] fix some javadoc errors in javax/swing/
yan
parents:
11268
diff
changeset
|
90 |
* index0 will always be <= index1. |
2 | 91 |
* |
92 |
* @param source the source Object (typically <code>this</code>) |
|
93 |
* @param type an int specifying {@link #CONTENTS_CHANGED}, |
|
94 |
* {@link #INTERVAL_ADDED}, or {@link #INTERVAL_REMOVED} |
|
95 |
* @param index0 one end of the new interval |
|
96 |
* @param index1 the other end of the new interval |
|
97 |
*/ |
|
98 |
public ListDataEvent(Object source, int type, int index0, int index1) { |
|
99 |
super(source); |
|
100 |
this.type = type; |
|
101 |
this.index0 = Math.min(index0, index1); |
|
102 |
this.index1 = Math.max(index0, index1); |
|
103 |
} |
|
104 |
||
105 |
/** |
|
106 |
* Returns a string representation of this ListDataEvent. This method |
|
107 |
* is intended to be used only for debugging purposes, and the |
|
108 |
* content and format of the returned string may vary between |
|
109 |
* implementations. The returned string may be empty but may not |
|
110 |
* be <code>null</code>. |
|
111 |
* |
|
112 |
* @since 1.4 |
|
113 |
* @return a string representation of this ListDataEvent. |
|
114 |
*/ |
|
115 |
public String toString() { |
|
116 |
return getClass().getName() + |
|
117 |
"[type=" + type + |
|
118 |
",index0=" + index0 + |
|
119 |
",index1=" + index1 + "]"; |
|
120 |
} |
|
121 |
} |