My Applet wont work. When i hit the buttons i get this Exception occured during event dispatching: java.lang.NullPointerException: then a long list of errors i guess...
this happens when i click the 2 buttons i made. i dont know why they dont work. Heres my code
public class EApplet extends Applet implements ActionListener { private Button keysArray[]; private Panel keyPad; private TextField lcdField; private TextField QuestionField; private Label ScoreLabel; private int Score; private int i; private String Questions[]; private int Answers[]; private boolean foundKey;
public void init() { foundKey = false; int i = 1; int[] Answers = new int[5]; String[] Questions = new String[5]; Questions[1] = "A Tomato is a vegetable."; Answers[1] = 0; Questions[2] = "You love this game."; Answers[2] = 1; Questions[3] = "Troy is an Idiot!"; Answers[3] = 1; Questions[4] = "The sun is warm."; Answers[4] = 1; lcdField = new TextField(20); QuestionField = new TextField(20);
I don't even believe this thing will compile, since you have stuff like "if(Answers == 0)" where Answers is an array.
By the way, if you use the java tag when you post, the code will be a lot more readable (see "Formatting Your Post" in the box on the right, when you are composing the post).