1 of 8 global variables not visible
I am writing a fairly simple program in the attempt to teach myself JAVA. I have 8 global variables, 3 JComboBoxes, 3 Calendar.instances, 1 int, and 1 JTextArea declared. All have been initialized. My ActionListener routine that services the JComboBoxes accesses or tries to access all of the global variables. It is successful on 7 of them, but I get a NULL reference pointer error at runtime on the JTextArea access. What am I doing wrong?
TIA,
Bobbo
1 of 8 global variables not visible
LINK REMOVED BY BOBBO
is a link to the source file. I am declaring the JTextArea variable jta on line 13. I initialize the jta variable on line 72. I am getting the error message at runtime on line 169. (It is currently commented out so it will run.) The error message is
Exception in thread "main" java.lang.NullPointerException
at working.Working.actionPerformed(Working.java:161)
at javax.swing.JComboBox.fireActionEvent(Unknown Source)
at javax.swing.JComboBox.setSelectedItem(Unknown Source)
at javax.swing.JComboBox.setSelectedIndex(Unknown Source)
at working.Working.run(Working.java:64)
at working.Working.main(Working.java:22)
The actual line giving the error is
jta.setText(result);
which puts the String variable result into the JTextArea for display.
1 of 8 global variables not visible
I have studied that code for days, and could have studied it for weeks without finding that. You are a genius. That fixed the problem.
Thanks, Bobbo :)
1 of 8 global variables not visible
Actually, I had placed that addActionListener statement prior to the dcb.setIndex() statement intentionally so the frame would open with the TextArea populated with that day's information. What I did to fix it was to move the instantiation of the JTextArea to the front of the routine so its pointer would no longer be NULL.
Bobbo