String mins = minsField.getText();
int Mins;
try
{
Mins = Integer.parseInt(mins);
}
catch (NumberFormatException e)
{
Mins = 0;
}
double hours = Mins / 60;
hours.setText(hoursminsfield);
The problem is that Double cannot be dereferenced.
EDIT 4/23/12
double cannot be dereferencedis the error some Java compilers give when you try to call a method on a primitive. It seems to medouble has no such methodwould be more helpful, but what do I know.From your code, it seems you think you can copy a text representation of
hoursintohoursminfieldby doinghours.setText(hoursminfield);
This has a few errors:
1) hours is a
doublewhich is a primitive type, there are NO methods you can call on it. This is what gives you the error you asked about.2) you don’t say what type hoursminfield is, maybe you haven’t even declared it yet.
3) it is unusual to set the value of a variable by having it be the argument to a method. It happens sometimes, but not usually.
The lines of code that do what you seem to want are:
ORIGINAL ANSWER (addressed a different problem in your code):
In
double hours = Mins / 60;you are dividing twoints. You will get theintvalue of that division, so ifMins = 43;
double hours = Mins / 60;
// Mins / 60 is an int = 0. assigning it to double hours makes
// hours a double equal to zero.
What you need to do is:
or something like that, you need to cast some part of your division to a
doublein order to force the division to be done withdoubles and notints.