0

Im working at step 4 of assignment 3. I have no errors in my code but i cant run the program. When i do try to run it, the following text is shown in the console:

readData() java.lang.NullPointerException at TemperaturePanel.(TemperaturePanel.java:53) at Assignment3GUI.(Assignment3GUI.java:43) at Assignment3GUI$1.run(Assignment3GUI.java:24) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$500(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)

Can anyone help me to solve this?

Share a link to this question (includes your user id)
| edit | | close | delete |
0

Show the code of TemperaturePanel.java. You can see in the error that something goes wrong at TemperaturePanel.java:53 (line 53 of TemperaturePanel.java).

I guess you are at step 4. Carefully re-read the assignment text of that step. Did you miss anything? Does your new constructor look like the example constructor given at "The new constructor now looks like ..."?

Share a link to this answer (includes your user id)
| edit | delete |
  • this is the code at the new constructor.:public TemperaturePanel(int id) { this(); // call base constructor w = new WeatherStation(id); //create new WeatherStation w String temp = w.readTemperature(); //read the temperature and set this to string temp lblTemp.setText(temp); //display temperature in the temperature label String stationname = w.readNameStation(); lblStationName.setText(stationname); } I don't have any errors in my code. Literally 0. So I'm really confused why i doesn't work – Levi manuel Heinen May 4 at 8:59    

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.