SpinnerListModel 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 list of items.

CrossRef.eps For more information, see JSpinner Class.

Constructors

Constructor

Description

SpinnerListModel (Object[]values)

Creates a list spinner model using the values from the specified array.

SpinerListModel(List collection)

Creates a list spinner model using the values from the specified collection. The collection must implement the List interface.

To create a JSpinner control that uses the SpinnerListModel class, pass an array or a collection to the SpinnerListModel constructor. For example:

String[] ampmString = {“am”, “pm”};

ampm = new JSpinner(

new SpinnerListModel(ampmString));

In this example, the spinner lets the user select choices from an array of strings that contains two items.

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.