jdk/src/share/classes/javax/swing/SpinnerModel.java
author dmarkov
Wed, 16 Apr 2014 12:51:25 +0400
changeset 24184 4da2f6ec4dab
parent 23010 6dadb192ad81
child 25760 7955db32d6b0
permissions -rw-r--r--
8032874: ArrayIndexOutOfBoundsException in JTable while clearing data in JTable Reviewed-by: alexp, alexsch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 21278
diff changeset
     2
 * Copyright (c) 2000, 2013, 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;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.swing.event.*;
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
 * A model for a potentially unbounded sequence of object values.  This model
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * is similar to <code>ListModel</code> however there are some important differences:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * <ul>
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 5506
diff changeset
    36
 * <li> The number of sequence elements isn't necessarily bounded.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * <li> The model doesn't support indexed random access to sequence elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *      Only three sequence values are accessible at a time: current, next and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *      previous.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * <li> The current sequence element, can be set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * A <code>SpinnerModel</code> has three properties, only the first is read/write.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * <dl>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *   <dt><code>value</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *   <dd>The current element of the sequence.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *   <dt><code>nextValue</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *   <dd>The following element or null if <code>value</code> is the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *     last element of the sequence.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *   <dt><code>previousValue</code>
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 5506
diff changeset
    53
 *   <dd>The preceding element or null if <code>value</code> is the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *     first element of the sequence.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * </dl>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * When the the <code>value</code> property changes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * <code>ChangeListeners</code> are notified.  <code>SpinnerModel</code> may
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * choose to notify the <code>ChangeListeners</code> under other circumstances.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * @see JSpinner
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * @see AbstractSpinnerModel
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * @see SpinnerListModel
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * @see SpinnerNumberModel
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * @see SpinnerDateModel
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * @author Hans Muller
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
public interface SpinnerModel
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * The <i>current element</i> of the sequence.  This element is usually
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * displayed by the <code>editor</code> part of a <code>JSpinner</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * @return the current spinner value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * @see #setValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    Object getValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * Changes current value of the model, typically this value is displayed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * by the <code>editor</code> part of a  <code>JSpinner</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * If the <code>SpinnerModel</code> implementation doesn't support
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * the specified value then an <code>IllegalArgumentException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * is thrown.  For example a <code>SpinnerModel</code> for numbers might
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * only support values that are integer multiples of ten. In
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * that case, <code>model.setValue(new Number(11))</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * would throw an exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * @throws IllegalArgumentException if <code>value</code> isn't allowed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @see #getValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    void setValue(Object value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * Return the object in the sequence that comes after the object returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * by <code>getValue()</code>. If the end of the sequence has been reached
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * then return null.  Calling this method does not effect <code>value</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * @return the next legal value or null if one doesn't exist
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * @see #getValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * @see #getPreviousValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    Object getNextValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * Return the object in the sequence that comes before the object returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * by <code>getValue()</code>.  If the end of the sequence has been reached then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * return null. Calling this method does not effect <code>value</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * @return the previous legal value or null if one doesn't exist
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * @see #getValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * @see #getNextValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    Object getPreviousValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * Adds a <code>ChangeListener</code> to the model's listener list.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * <code>ChangeListeners</code> must be notified when models <code>value</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * changes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * @param l the ChangeListener to add
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * @see #removeChangeListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    void addChangeListener(ChangeListener l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * Removes a <code>ChangeListener</code> from the model's listener list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * @param l the ChangeListener to remove
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * @see #addChangeListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    void removeChangeListener(ChangeListener l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
}