[填空题] 请完善程序(程序文件名:Java_3.java)并进行调试。请在下画线处填入正确内容,然后删除下画线。请勿删除注释行和其他已有的语句内容。 题目要
[填空题] 请完善程序(程序文件名:Java_3.java)并进行调试。请在下画线处填入正确内容,然后删除下画线。请勿删除注释行和其他已有的语句内容。
题目要求:
程序运行的窗口(如下图所示)。
并在命令行窗口中每隔1秒显示一下当前时间,类似:
At the tone, the time is Tue Dec 29 11:40:12 CST 2009
At the tone, the time is Tue Dec 29 11:40:13 CST 2009
At the tone, the time is Tue Dec 29 11:40:14 CST 2009
在单击“确定”按钮时自动退出程序。
源程序:
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.Timer;
public class Java_3
public static void main(String[]args)
ActionListener listener=new (1) ();
Timer t=new Timer(1000, listener);
t.start();
JOptionPane.showMessageDialog(null, "Quit program");
System.exit(0);
class
正确答案:implements
参考解析:因为类中用到了ActionListener的方法actionPerformed,所以TimePrinter实现了ActionListener接口,实现接口需要用implements关键字。
词条内容仅供参考,如果您需要解决具体问题
(尤其在法律、医学等领域),建议您咨询相关领域专业人士。