Originally posted by Alex Bruhart:
... The weird thing is, it works except for when the user selects "Mr." When that happens, it prints "null" in the textArea. Why is this? Thanks!
I think you mean it works except for when the user
does not select anything, and just leaves the default of "Mr." showing in the comboBox.
It looks like preName is only assigned a new value if the actionPerformed method is invoked, which only happens if the user
changes the selection in the comboBox. If they leave the default of "Mr.", then actionPerformed doesn't run, and preName still has its default null value.
(Note: If the user selects a different value first, but then goes back and selects "Mr," then it works because the method runs on the change.)
So you need to make sure that preName gets a value even if actionPerformed doesn't run.