java:java中的Interface的应用,我…

来源:互联网 发布:彩虹六号数据查询 编辑:程序博客网 时间:2024/06/15 04:33
package com.xudeyu.interfacee;

import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Date;

import javax.swing.JOptionPane;
import javax.swing.Timer;

import static java.lang.System.*;

public class Interface
{

public static void main(String[] args)
{
ActionListener act_time = new TimPrinter();
Timer t = new Timer(1000, act_time);
t.start();
JOptionPane.showMessageDialog(null, "Quit program?");
exit(0);

}

}

class TimPrinter implements ActionListener
{
Date now = new Date();

@Override
public void actionPerformed(ActionEvent e)
{
out.println("At the tone ,the time is " + now);
Toolkit.getDefaultToolkit().beep();
}

}

0 0
原创粉丝点击