Java JSpinner setList(JSpinner spinner, List values)

Here you can find the source of setList(JSpinner spinner, List values)

Description

Assign the List model (for a list-based spinner)

License

Open Source License

Parameter

Parameter Description
spinner the spinner to update
values the model list values

Declaration

public static void setList(JSpinner spinner, List<?> values) 

Method Source Code

//package com.java2s;
// it under the terms of the GNU General Public License as published by

import java.util.List;

import javax.swing.JSpinner;

import javax.swing.SpinnerListModel;
import javax.swing.SpinnerModel;

public class Main {
    /**//  ww w .j a  v  a 2 s .  c o  m
     * Assign the List model (for a list-based spinner)
     *
     * @param spinner the spinner to update
     * @param values  the model list values
     */
    public static void setList(JSpinner spinner, List<?> values) {
        SpinnerModel model = spinner.getModel();

        if (model instanceof SpinnerListModel) {
            ((SpinnerListModel) model).setList(values);
        } else {
            throw new IllegalArgumentException("Spinner model is not a SpinnerListModel");
        }
    }
}

Related

  1. getSpinnerIntValue(final JSpinner spinner)
  2. getSpinnerIntValue(JSpinner spin)
  3. installSpinnerBugWorkaround(final JSpinner spinner)
  4. reattachChangeListeners(JSpinner spinner, ChangeListener[] listeners)
  5. replaceSpinnerValue(JSpinner spinner, double value)
  6. setRightAlignment(JSpinner spinner)
  7. setSpinnerFloatValue(JSpinner sp, float f)
  8. setSpinnerValue(JSpinner spinner, Integer i)