Java JSpinner getSpinnerFloatValue(JSpinner sp)

Here you can find the source of getSpinnerFloatValue(JSpinner sp)

Description

Utility function to access the spinner value.

License

BSD License

Parameter

Parameter Description
sp a parameter

Declaration

public static float getSpinnerFloatValue(JSpinner sp) 

Method Source Code

//package com.java2s;
// LICENSE:      This file is distributed under the BSD license.

import javax.swing.JSpinner;

public class Main {
    /**//from  www . j  ava2 s  .  com
     * Utility function to access the spinner value.
     * @param sp
     * @return
     */
    public static float getSpinnerFloatValue(JSpinner sp) {
        // TODO figure out why the type of value in the numbermodel is 
        // changing type to float which necessitates this code
        float f;
        try {
            f = (float) ((Double) sp.getValue()).doubleValue();
        } catch (Exception ex) {
            f = ((Float) sp.getValue()).floatValue();
        }
        return f;
    }
}

Related

  1. generateSpinnerFor(Object... objs)
  2. getFloat(JSpinner spinner)
  3. getInt(JSpinner spinner)
  4. getInt(SpinnerNumberModel model)
  5. getOnlySpinner(Container owner)
  6. getSpinnerFormatter(JSpinner spinner)
  7. getSpinnerInt(JSpinner aSpinner)
  8. getSpinnerIntValue(final JSpinner spinner)
  9. getSpinnerIntValue(JSpinner spin)