我有這樣的代碼:嘗試運行簡單的Java ActionListener示例並獲取錯誤?
import javax.swing.*;
import java.util.*;
import java.awt.*;
public class Stu {
public static void main(String[] args){
int dl = 3000;
ActionListener taskPerformer = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
System.out.print("do");//do a task
}
};
}
}
,這讓我這個錯誤:
Stu.java:9: error: cannot find symbol
ActionListener taskPerformer = new ActionListener() {
我需要幫助瞭解如何工作的。 ActionListener是否需要GUI來運行?謝謝
您尚未導入'ActionListener'。 –
@SotiriosDelimanolis - 好的,我會這樣做的。謝謝!! – Coffee