내 actionListener에 문제가 있습니다. 버튼을 클릭하기 전에 actionListener가 자동으로 실행되는 것 같습니다. I 버튼 "...이 이상하다을 클릭하기 전에 은"이 버튼을 클릭하기 전에 콘솔에 표시되지해야한다 "콘솔에 나타납니다.ActionListener 문제
이....
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");
.....
}
addActionListener()의 컨텍스트를 게시 할 수 있습니까? –
버튼을 클릭하면 public void actionPerformed (ActionEvent e) {} 메소드가 호출됩니다. 하지만 제 경우에는 단추를 클릭하기 전에 자동으로 메서드를 실행하는 것처럼 보입니다. – Jessy