• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 152
  • Last Modified:

Applet Question : Have an applet and want to print out calculations

Hello,
I was wondering if anyone could answer me this question. I have an applet that works out a calculation based on what the user chooses from a Choice() box. So , say , for example i have
if(choice.getSelectedIndex() == 1)
{
     a = (b - (c * a))
}
else if(choice.getSelectedIndex() == 2)
{
     b = b * b
}

and so on.
How do I print this out to a seperate frame. ?
I already have a seperate frame already but it is just printing out a or b but not the results.



0
confuddled
Asked:
confuddled
  • 3
  • 2
1 Solution
 
pronaneCommented:
where have you declared a or b?  have you declared them so that wherever you print them to the frame they can be seen so that if a calculation has been made it will be seen by all that are using/need a or b? also try printing out a or b to the console after the calculation has been made to make sure they are changing.
0
 
confuddledAuthor Commented:
a and b are global variables.
the calculation are defintely changing. I 've checked that using appletviewer. What I asked is not too clear. I'll rephrase this question.

I have the following variables

int Lap;
     double Distance, LengthOfPit, totalRaceDistance, FuelPerLap, currentLap, FrontWing, RearWing, DriveT, StopG, distanceLeft, lapsLeft, AmountToFuel, stop1, stop2, stop3, FuelRig,EngineCapacity, safetyLap, yLap, rLap;

and have this following also

else if(ie.getSource().equals((Object)track)) //if the track was selected
{
switch (track.getSelectedIndex())
{
     case 0:
       //Melbourne
     Lap = 58;
     Distance = 5.303;
     LengthOfPit = 16.0;
     totalRaceDistance = Lap * Distance;
     currentLap = Clap.getSelectedIndex() + 1;
     if (currentLap<=0 || currentLap>58)
     {
     currentLap = 0;
     }
        distanceLeft = (totalRaceDistance - (currentLap * Distance));
     lapsLeft = distanceLeft / Distance;
     AmountToFuel = FuelPerLap * lapsLeft;
     break;

        etc....................................

I then have this what i want to print out

       stop 1 = ((AmountToFuel / FuelRig) + LengthOfPit)

Now what i want to do is print stop1 in a seperate frame. I have no problem creating this frame but i do have a problem printing stop1 to the frame. I hope that cleared it up.

     
0
 
ExceterCommented:
Have you tried something like,

Label l = new Label( stop.toString() );

frame1.getContentPane().add( l )

Exceter
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
confuddledAuthor Commented:
that's about it
thanks
0
 
confuddledAuthor Commented:
that's about it
thanks
0
 
ExceterCommented:
You are most welcome.
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now