Java JSpinner getSpinnerIntValue(JSpinner spin)

Here you can find the source of getSpinnerIntValue(JSpinner spin)

Description

Evaluates the numeric int value of a spinner object

License

Open Source License

Parameter

Parameter Description
spin JSpinner

Return

int value of the spinner value

Declaration

public static int getSpinnerIntValue(JSpinner spin) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.swing.JSpinner;

public class Main {
    /**// w  w  w .  ja  v  a2  s  . c o m
     * Evaluates the numeric int value of a spinner object
     * 
     * @param spin
     *            JSpinner
     * @return int value of the spinner value
     */
    public static int getSpinnerIntValue(JSpinner spin) {
        return getSpinnerDoubleValue(spin).intValue();
    }

    /**
     * Evaluates the numeric double value of a spinner object
     * 
     * @param spin
     *            JSpinner
     * @return double value of the spinner value
     */
    public static Double getSpinnerDoubleValue(JSpinner spin) {
        Double d = 0.0;
        int i = 0;
        if (spin.getValue().getClass() == Double.class
                || spin.getValue().getClass() == double.class) {
            d = (double) spin.getValue();
        }
        if (spin.getValue().getClass() == Integer.class
                || spin.getValue().getClass() == int.class) {
            i = (Integer) spin.getValue();
            d = (double) i;
        }
        return d;
    }
}

Related

  1. getOnlySpinner(Container owner)
  2. getSpinnerFloatValue(JSpinner sp)
  3. getSpinnerFormatter(JSpinner spinner)
  4. getSpinnerInt(JSpinner aSpinner)
  5. getSpinnerIntValue(final JSpinner spinner)
  6. installSpinnerBugWorkaround(final JSpinner spinner)
  7. reattachChangeListeners(JSpinner spinner, ChangeListener[] listeners)
  8. replaceSpinnerValue(JSpinner spinner, double value)
  9. setList(JSpinner spinner, List values)