小弟想请问一下 下列的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");
}
}