Skip to main content

JSpinner help - New to java

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
Niixie
Offline
Joined: 2011-08-19

Hello Java people!

Hello people, I have a problem!

I'm trying to make a program for my computer, in the design of the program there's three JSpinners.
The first JSpinner is called "Hour" and needs to be multiplyed twice with 60. (Hour * 60 * 60)
The JSpinner var is Object, and I think thats why i cant do it? I tried to do like this "int fullHour = Hour*60*60;" But had an error.

These are the variables in my code:

Object Hour = HourField.getValue(); //Needs to be timed twice with 60 (Hour*60*60)
Object Min = MinuteField.getValue();
Object Sec = SecondField.getValue();

I am very new to Java, and i really can't figure this out, and i've been searching for 2 days.

Can you help me?
Thanks in advance

Niixie

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
phil1234
Offline
Joined: 2011-07-15

What are HourField, MinuteField and SecondField?

if they are text fields or something, you can just write

int hour = Integer.parseInt(HourField.getValue());
int min  = Integer.parseInt(HourField.getValue());
int sec  = Integer.parseInt(HourField.getValue());

Then you can just treat them as numbers and multiply them by 60 etc.