Link to home
Start Free TrialLog in
Avatar of craftyfirst
craftyfirstFlag for Afghanistan

asked on

Getting the chart to work in my Java program

I need to get my chart to work in the Java program I have developed. I have gotten the basic layout to work, but have not gotten the information from the calculations to work to make the graph. Let me know what I'm doing wrong.  MortgageCalculator.java Chart.java InterestRate-Term.txt
Avatar of for_yan
for_yan
Flag of United States of America image

It is not printing because yiou use number of months instaed of number of yaerss
and when it comapres number of montsh with 10 in your chart
it odes not go
to that picve which should darw your red line

This code is from your caclulator part
    public void onButtonChart()
            {
                new Chart((int)(number_of_months));
                System.out.println(""+number_of_months);

        }

Open in new window



This code is from Chart:


public Chart( int number_years)
   {
            //set title for the window
            super( "Mortgage Payment Calculator Chart" );

            this.number_years = number_years ;


	  // set the size of the window and let it be visible
	  setSize( 740, 490 );
	  setVisible( true );

   }

So you pass number of months and read it as number of years.

Open in new window



ASKER CERTIFIED SOLUTION
Avatar of for_yan
for_yan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of craftyfirst

ASKER

Thanks. Looks like it working.

Yes, it does.
In general it is definitely not a good practice to
use actual numbers in the paint(g) method.
You should first retrieve the size of yoour panel
and then exprsess everithyng as height and width mmultuiplied by the
ratio which you need for each point, line, etc
which you are drawing.
Otherwise, when you resize your window, your
drawing will be screwed up.
Well, for the first try - it is OK.
But in general, this is good to keep in mind.
 
Thanks

I will keep this in mind for next time.