Java JSpinner getSpinnerInt(JSpinner aSpinner)

Here you can find the source of getSpinnerInt(JSpinner aSpinner)

Description

Gets the currently selected integer value in a spinner control.

License

Open Source License

Parameter

Parameter Description
aSpinner Spinner, whose chosen value is to be extracted.

Exception

Parameter Description
ClassCastException If the spinner's model is not a javax.swing.SpinnerNumberModel.

Return

The selected value of the spinner rounded to integer.

Declaration

public static int getSpinnerInt(JSpinner aSpinner) 

Method Source Code

//package com.java2s;
/*//from  ww  w .  ja  v  a 2  s. c o m
 * Copyright (c) 2006, 2007, 2008, 2010, Max Planck Institute for Informatics, Saarbruecken, Germany.
 *
 * This file is part of NetworkAnalyzer.
 * 
 * NetworkAnalyzer is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
 * any later version.
 * 
 * NetworkAnalyzer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
 * for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License along with NetworkAnalyzer. If not, see
 * <http://www.gnu.org/licenses/>.
 */

import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;

public class Main {
    /**
     * Gets the currently selected integer value in a spinner control.
     * 
     * @param aSpinner
     *            Spinner, whose chosen value is to be extracted.
     * @return The selected value of the spinner rounded to integer.
     * @throws ClassCastException
     *             If the spinner's model is not a {@link javax.swing.SpinnerNumberModel}.
     */
    public static int getSpinnerInt(JSpinner aSpinner) {
        return ((SpinnerNumberModel) aSpinner.getModel()).getNumber()
                .intValue();
    }
}

Related

  1. getInt(JSpinner spinner)
  2. getInt(SpinnerNumberModel model)
  3. getOnlySpinner(Container owner)
  4. getSpinnerFloatValue(JSpinner sp)
  5. getSpinnerFormatter(JSpinner spinner)
  6. getSpinnerIntValue(final JSpinner spinner)
  7. getSpinnerIntValue(JSpinner spin)
  8. installSpinnerBugWorkaround(final JSpinner spinner)
  9. reattachChangeListeners(JSpinner spinner, ChangeListener[] listeners)