View Single Post
  #2 (permalink)  
Old 07-31-2007, 03:57 AM
hardwired hardwired is offline
Senior Member
 
Join Date: Jul 2007
Posts: 1,266
hardwired is on a distinguished road
The first thing I notice in looking at your GraphPanel class is that you did not assign the member variables (principalData, interestData) to the local variables (p, i) in the constructor. This leaves the member variables with the value of null and, when running the class liks this results in this exception in the console:
Code:
C:\jexp>java MC Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at GraphPanel.paintComponent(mc.java:311)
Make the assignment in your constructor with
Code:
public GraphPanel(float[] p, float[] i) { principalData = p; interestData = i; font = new Font("lucida sans regular", Font.PLAIN, 16); setBackground(Color.white); }
and see what happens.

About your last thread:
When I posted a recommendation to change setEnabled to setFocusable on the monthlyPaymentTxt I meant that you should replace the first, setEnabled line with the second, setFocusable line. Use one or the other, not both.
Code:
// Eliminate/remove this next line. // monthlyPaymentTxt.setEnabled(false); //set payment amount uneditable // Leave this line in. monthlyPaymentTxt.setFocusable(false);
Also, this comment can be removed from the ActionListener
Code:
// You need to use the member variables with these two names // so you can send them to your GraphPanel. Instantiate them // here and fill the elements in this loop. The member // variables remain null and choke up GraphPanel.
We handled it in the last post and I forgot to remove it.
Reply With Quote