1 /*
2 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
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 *
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
63 * for these cases are provided. For example to create the model in
64 * the previous example, one could also write:
65 * <pre>
66 * SpinnerNumberModel model = new SpinnerNumberModel(50, 0, 100, 1);
67 * </pre>
68 * <p>
69 * This model inherits a <code>ChangeListener</code>.
70 * The <code>ChangeListeners</code> are notified
71 * whenever the model's <code>value</code>, <code>stepSize</code>,
72 * <code>minimum</code>, or <code>maximum</code> properties changes.
73 *
74 * @see JSpinner
75 * @see SpinnerModel
76 * @see AbstractSpinnerModel
77 * @see SpinnerListModel
78 * @see SpinnerDateModel
79 *
80 * @author Hans Muller
81 * @since 1.4
82 */
83 public class SpinnerNumberModel extends AbstractSpinnerModel implements Serializable
84 {
85 private Number stepSize, value;
86 private Comparable minimum, maximum;
87
88
89 /**
90 * Constructs a <code>SpinnerModel</code> that represents
91 * a closed sequence of
92 * numbers from <code>minimum</code> to <code>maximum</code>. The
93 * <code>nextValue</code> and <code>previousValue</code> methods
94 * compute elements of the sequence by adding or subtracting
95 * <code>stepSize</code> respectively. All of the parameters
96 * must be mutually <code>Comparable</code>, <code>value</code>
97 * and <code>stepSize</code> must be instances of <code>Integer</code>
98 * <code>Long</code>, <code>Float</code>, or <code>Double</code>.
99 * <p>
100 * The <code>minimum</code> and <code>maximum</code> parameters
101 * can be <code>null</code> to indicate that the range doesn't
102 * have an upper or lower bound.
|
1 /*
2 * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
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 *
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
63 * for these cases are provided. For example to create the model in
64 * the previous example, one could also write:
65 * <pre>
66 * SpinnerNumberModel model = new SpinnerNumberModel(50, 0, 100, 1);
67 * </pre>
68 * <p>
69 * This model inherits a <code>ChangeListener</code>.
70 * The <code>ChangeListeners</code> are notified
71 * whenever the model's <code>value</code>, <code>stepSize</code>,
72 * <code>minimum</code>, or <code>maximum</code> properties changes.
73 *
74 * @see JSpinner
75 * @see SpinnerModel
76 * @see AbstractSpinnerModel
77 * @see SpinnerListModel
78 * @see SpinnerDateModel
79 *
80 * @author Hans Muller
81 * @since 1.4
82 */
83 @SuppressWarnings("serial") // Superclass is not serializable across versions
84 public class SpinnerNumberModel extends AbstractSpinnerModel implements Serializable
85 {
86 private Number stepSize, value;
87 private Comparable minimum, maximum;
88
89
90 /**
91 * Constructs a <code>SpinnerModel</code> that represents
92 * a closed sequence of
93 * numbers from <code>minimum</code> to <code>maximum</code>. The
94 * <code>nextValue</code> and <code>previousValue</code> methods
95 * compute elements of the sequence by adding or subtracting
96 * <code>stepSize</code> respectively. All of the parameters
97 * must be mutually <code>Comparable</code>, <code>value</code>
98 * and <code>stepSize</code> must be instances of <code>Integer</code>
99 * <code>Long</code>, <code>Float</code>, or <code>Double</code>.
100 * <p>
101 * The <code>minimum</code> and <code>maximum</code> parameters
102 * can be <code>null</code> to indicate that the range doesn't
103 * have an upper or lower bound.
|