A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.oracle.com/javase/8/docs/api/javax/swing/SpinnerNumberModel.html below:

SpinnerNumberModel (Java Platform SE 8 )

A

SpinnerModel

for sequences of numbers. The upper and lower bounds of the sequence are defined by properties called

minimum

and

maximum

. The size of the increase or decrease computed by the

nextValue

and

previousValue

methods is defined by a property called

stepSize

. The

minimum

and

maximum

properties can be

null

to indicate that the sequence has no lower or upper limit. All of the properties in this class are defined in terms of two generic types:

Number

and

Comparable

, so that all Java numeric types may be accommodated. Internally, there's only support for values whose type is one of the primitive

Number

types:

Double

,

Float

,

Long

,

Integer

,

Short

, or

Byte

.

To create a SpinnerNumberModel for the integer range zero to one hundred, with fifty as the initial value, one could write:

 Integer value = new Integer(50);
 Integer min = new Integer(0);
 Integer max = new Integer(100);
 Integer step = new Integer(1);
 SpinnerNumberModel model = new SpinnerNumberModel(value, min, max, step);
 int fifty = model.getNumber().intValue();
 

Spinners for integers and doubles are common, so special constructors for these cases are provided. For example to create the model in the previous example, one could also write:

 SpinnerNumberModel model = new SpinnerNumberModel(50, 0, 100, 1);
 

This model inherits a ChangeListener. The ChangeListeners are notified whenever the model's value, stepSize, minimum, or maximum properties changes.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4