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