R
Rhino
1. If I create a JSpinner with a SpinnerNumberModel and specify the numbers
in the model explicitly as short, why can't I rely on the getValue() from
the JSpinner always returning shorts? In other words, if I define it all
with shorts, what actions on my part will result in getValue() returning an
Integer or something other than Short? For some reason, the results from
getValue() are sometimes Short but sometimes Integer and I don't understand
why. I'm trying to figure out how to make getValue() return ONLY Short (or,
failing that, to return only Integer.) This is the statement that defined
the model:
SpinnerNumberModel seasonNumberModel = new SpinnerNumberModel((short)1,
(short)1, (short)20, (short)1);
2. If a given method can return various sorts of integer numbers, like
Short, Integer, and Long, what is the simplest way to determine the exact
type that is being returned by the method? I'm just trying to cover the
worst-case scenario that factors beyond my control may make it impossible
to predict whether getValue() is going to return Integer or Short from my
JSpinner. If that turns out to be true, I'd like to know the best way to
determine if a given value is a short, int, long or anything else. I think
I used to know how to do that several years ago but I'm darned if I can
remember that technique now.
in the model explicitly as short, why can't I rely on the getValue() from
the JSpinner always returning shorts? In other words, if I define it all
with shorts, what actions on my part will result in getValue() returning an
Integer or something other than Short? For some reason, the results from
getValue() are sometimes Short but sometimes Integer and I don't understand
why. I'm trying to figure out how to make getValue() return ONLY Short (or,
failing that, to return only Integer.) This is the statement that defined
the model:
SpinnerNumberModel seasonNumberModel = new SpinnerNumberModel((short)1,
(short)1, (short)20, (short)1);
2. If a given method can return various sorts of integer numbers, like
Short, Integer, and Long, what is the simplest way to determine the exact
type that is being returned by the method? I'm just trying to cover the
worst-case scenario that factors beyond my control may make it impossible
to predict whether getValue() is going to return Integer or Short from my
JSpinner. If that turns out to be true, I'd like to know the best way to
determine if a given value is a short, int, long or anything else. I think
I used to know how to do that several years ago but I'm darned if I can
remember that technique now.