SpinnerNumberModel Class
Package: javax.swing
Using this provides an implementation of the SpinnerModel
interface from which you create JSpinner
controls that let the user select from a range of numbers.
Constructors
Constructor |
Description |
|
Creates a number spinner model that lets the user select integer values ranging from |
|
Creates a number spinner model that lets the user select double values ranging from |
The first, SpinnerNumberModel
, creates numeric spinner controls that let you control the initial value, the minimum and maximum values, and the step value that’s added or subtracted each time the user clicks one of the arrows.
Here’s how you can use the SpinnerNumberModel
to create a spinner that accepts integers from 1 to 12, starting with 1:
JSpinner hours = new JSpinner(
new SpinnerNumberModel(1, 1, 12, 1));
Get Java For Dummies Quick Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.