473,327 Members | 2,007 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

NullPointerException Error

Hi

Im having a problem with some code. Originally, the application was set into three packages (script, gui and control). I have changed is so there is a fourth called 'report'. Whenever I call upon anything in the report package though, there is a NullPointerException for the 'report' variable (which identifies the location of the report. The below part is where the problem occurs:

private void injuriesMouseClicked(java.awt.event.MouseEvent evt)
{
Injuries = true;

report.reportInfo();
}

In the above part both the report and Injuries variables are populated with the correct information

In some circumstances (this is the wierd thing), the reportInfo class is accessed, but when I try to retrieve the value of 'report' to check the value, the execution refuses to print out anything in the report.reportInfo class. But when I print out a random bit of text it prints it out fine. Whenever I try both it does nothing!! The code in report.reportInfo is below:

public class ReportData implements ScriptThread, Runnable
{
private DCWorkbenchGUI gui;
private VppController control;
private ComplexScript script;

//state variables for the script
public int publicDisorder = 0;
public int soldierInjuries = 0;
public int publicInjuries = 0;
public int civilanFireInjuries = 0;
public int civilanFireFatalities = 0;
public int soldierFatalities = 0;
public int suspectApprehension = 0;
public int baseDamage = 0;
public int pressCoverage = 0;

/**
* Constructor for the ReportData thread
*
* @param g the gui
* @param c the controller
* @param s the script
*/
public ReportData(DCWorkbenchGUI g, VppController c, ComplexScript s)
{
gui = g;
control = c;
script = s;
}

/**
* This method is that which will be invoked when the method is called upon
*/
public void run()
{
reportInfo();
}

/**
* Method to represent the action for the report information
*/
public void reportInfo()
{
System.out.println("reportInfo: ");
if (gui.Injuries = true)
{
String Injuries = ("Soldier Injuries (max 27): " + soldierInjuries +"\n" +
"Public Injuries (max 20): " + publicInjuries +"\n" +
"Civilian Emergency Services Injuries (max 10): " + civilanFireInjuries);

//display info dialog to the user
gui.scenInfo("The following information has been found by your assistant \n"+ Injuries,
"General Information",
script.currentTimeInSecs());
gui.Injuries = false;
}


EndReport();

}
}

*******************************************

The errors are below:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at dcw.report.ReportData.reportInfo(ReportData.java:5 9)
at dcw.gui.DCWorkbenchGUI.injuriesMouseClicked(DCWork benchGUI.java:234)
at dcw.gui.DCWorkbenchGUI.access$000(DCWorkbenchGUI.j ava:34)
at dcw.gui.DCWorkbenchGUI$1.mouseClicked(DCWorkbenchG UI.java:161)
at java.awt.AWTEventMulticaster.mouseClicked(AWTEvent Multicaster.java:253)
at java.awt.Component.processMouseEvent(Component.jav a:6044)
at javax.swing.JComponent.processMouseEvent(JComponen t.java:3265)
at java.awt.Component.processEvent(Component.java:580 6)
at java.awt.Container.processEvent(Container.java:205 8)
at java.awt.Component.dispatchEventImpl(Component.jav a:4413)
at java.awt.Container.dispatchEventImpl(Container.jav a:2116)
at java.awt.Component.dispatchEvent(Component.java:42 43)
at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4322)
at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:3995)
at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:3916)
at java.awt.Container.dispatchEventImpl(Container.jav a:2102)
at java.awt.Window.dispatchEventImpl(Window.java:2440 )
at java.awt.Component.dispatchEvent(Component.java:42 43)
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 599)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:121)
Mar 19 '08 #1
1 1165
Stang02GT
1,208 Expert 1GB
Welcome to the Scripts,

Your question appears to be Java related. For future reference try to post language specific questions in the appropriate forums. This way you will get a faster/better answer.


Thanks and Enjoy!
Mar 19 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Old-timer | last post by:
Not sure where else to post this. I'm sure I'm doing something wrong, but I wouldn't think a simple app would give me so much trouble. I've got a small test java class that I'm trying to have...
2
by: Charles | last post by:
I was able to do this but for no reason I can think of, now I cannot login to my Oracle Management Server. When Oracle Enterprise Manager starts up and I choose to login to OMS, it throws up a java...
1
by: ketand1 | last post by:
import java.awt.*; import java.awt.event.*; import java.io.*; import java.util.*; import java.sql.*; import java.lang.*; class DbAwt extends Frame implements ActionListener { private...
2
by: dragonridingsorceress | last post by:
I am trying to learn how to use the JFileChooser. I'm working in BlueJ. I keep getting a NullPointerException. Full text of the error message is at the bottom of the post. My code is based on some...
3
by: chris123456789 | last post by:
Hi, when I run my code I get a NullPointerException:null. Here is the part of the code where the error occurs: import java.util.*; import java.io.*; public class Decrypt { ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.