Here you can find the source of setSpinnerFloatValue(JSpinner sp, float f)
Parameter | Description |
---|---|
sp | - spinning that should be set |
f | - new value for the spinner |
public static void setSpinnerFloatValue(JSpinner sp, float f)
//package com.java2s; // LICENSE: This file is distributed under the BSD license. import javax.swing.JSpinner; public class Main { /**// w ww . j a va 2s . c om * Utility function to write to the spinner value. * @param sp - spinning that should be set * @param f - new value for the spinner */ public static void setSpinnerFloatValue(JSpinner sp, float f) { // TODO figure out why the type of value in the numbermodel is // changing type to float which necessitates this code // this should call change listener try { sp.setValue((Double) ((double) f)); } catch (Exception ex) { sp.setValue((Float) f); } } /** * Utility function to write to the spinner value. * @param sp spinner whole value should be set * @param d new value for the spinner */ public static void setSpinnerFloatValue(JSpinner sp, double d) { // TODO figure out why the type of value in the numbermodel is // changing type to float which necessitates this code try { sp.setValue((Double) d); } catch (Exception ex) { sp.setValue((Float) ((float) d)); } } }