小弟想請問一下 下列的codet重複印出go 但是ActionListener沒有被別指定button
請問ActionListener是不是只要有event dispatch thread 就會被trigger?
import javax.swing.Timer;
import javax.swing.JFrame;
public class MyClass {
public static void main(String[] args) {
Timer t = new Timer(400, new MyF());
t.setRepeats(true);
t.start();
JFrame MyFrame=new JFrame();
MyFrame.setVisible(true);
}
}
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class MyF implements ActionListener {
@Override
public void actionPerformed(ActionEvent arg0) {
System.out.println("Go");
}
}