I just started to try and learn Java and in making a program to practise I have run into an issue and was hoping smoeone could help me.
I'm sure it is something very basic but I can't spot it.
I have a '+' button that when clicked add the value of a text field into an integer variable.
Below is the code:
private void cmdPlusActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
intTotal=intTotal + Integer.parseInt(txtDisplay.getText());
}
I get a whole bunch of errors like below:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
I thought maybe what I was doing to convert the text into integer was wrong, but even if I replace with something like:
intTotal=intTotal + 1;
It gives me the same error so I'm not sure what I am doing wrong.