I have a problem with my actionListener. It seems that the actionListener runs automatically before I click the button? The "This should not appear in the console before button click" appear in the console before I click the button".... This is strange.
....
button1.addActionListener(this);
button2.addActionListener(this);
....
public void actionPerformed(ActionEvent e) {
System.out.println("This should not appear in the console before button click");
if (e.getSource()==button1)
System.out.println ("answer1");
else if (e.getSource()==button2)
System.out.println ("answer2");
.....
}