int return in JSpinner.  
Author Message
nobody





PostPosted: 2003-7-31 21:56:00 Top

java-programmer, int return in JSpinner. "Matteo Finistauri" <email***@***.com> writes:
> I'd like to have the int value in a JSpinner. I tryed in this way:
> int h = MySpin.getValue();
> but it doesn't work. I tried to cast the value like this:
> int h = (int) MySpin.getValue();
> but it doesn't work.

Why should it? You can't cast Object to int.

> What can I do????? Thank you!

If you use a SpinnerNumberModel, then

((Number)MySpin.getValue()).intValue()

or

((SpinnerNumberModel)MySpin.getModel()).getNumber().intValue()

/Thomas