JSpinner & unlimited max value

M

Mike Mimic

Hi!

Why this does not work:

new JSpinner(new SpinnerNumberModel(1, 1, null, 1));

I get this compiler error:

cannot resolve symbol
symbol: constructor SpinnerNumberModel (int,int,<nulltype>,int)

But in the documentation it is written:

The minimum and maximum properties can be null to indicate that the
sequence has no lower or upper limit.


Mike
 
C

Christophe Vanfleteren

Mike said:
Hi!

Why this does not work:

new JSpinner(new SpinnerNumberModel(1, 1, null, 1));

I get this compiler error:

cannot resolve symbol
symbol: constructor SpinnerNumberModel (int,int,<nulltype>,int)

But in the documentation it is written:

The minimum and maximum properties can be null to indicate that the
sequence has no lower or upper limit.


Mike

You're using the wrong constructor (and you cant use null when a primitive
type, in this case int, is expected).

Take a closer look at the api docs for the correct constructor:
http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/SpinnerNumberModel.html
 
L

Laurens

Mike Mimic said:
Why this does not work:

new JSpinner(new SpinnerNumberModel(1, 1, null, 1));

Look closely. You need the constructor that takes Numbers and Comparable
instances, not the constructor that takes ints, which is the one you are
calling.

Example:
new SpinnerNumberModel(new Integer(50), new Integer(1), null, new
Integer(1));


Regards
-Laurens
 
T

Thomas Schodt

Mike said:
Why this does not work:

new JSpinner(new SpinnerNumberModel(1, 1, null, 1));

I get this compiler error:

cannot resolve symbol
symbol: constructor SpinnerNumberModel (int,int,<nulltype>,int)

But in the documentation it is written:

The minimum and maximum properties can be null to indicate that the
sequence has no lower or upper limit.

Either the primitive int you pass for minimum (try Integer)
or you need to cast null.

Try

new JSpinner(
new SpinnerNumberModel(1, new Integer(1), (Comparable)null, 1)
);
 
M

Mike Mimic

Hi!
Look closely. You need the constructor that takes Numbers and Comparable
instances, not the constructor that takes ints, which is the one you are
calling.

Example:
new SpinnerNumberModel(new Integer(50), new Integer(1), null, new
Integer(1));

Thanks to all of you. Now it works.


Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top