弄个线程,程序开始的时候让它运行,运行起来就sleep7分钟,醒了就通知,呵呵。

解决方案 »

  1.   


    thread.sleep(7000);
    //sound
    thread.sleep(1000);
    //sound精确到毫秒!
      

  2.   

    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;public class applet7 extends Applet implements Runnable
    {
            Image memoryimage;
            Graphics memorygraphics;
            Thread doublebufferthread;
            boolean animateFlag = true;
            long t=System.currentTimeMillis();
            double d;
            //Initialize the applet
            public void init()
            {
                    memoryimage = createImage(100,100);
                    memorygraphics = memoryimage.getGraphics();
            }        public void start()
            {
                    doublebufferthread = new Thread(this);
                    doublebufferthread.start();
            }        public void stop()
            {
                    animateFlag = false;
            }        public void run()
            {
                    try
                    {
                      while(true) {
                        Thread.sleep(100);
                        long t1=System.currentTimeMillis();
                        d=(double)(t1-t)/1000;
                        repaint();
                        if(d>=10)//这里设置到时时间,这里为10秒
                          break;
                      }
                      this.getToolkit().beep();//这里发出提示的声音
                      javax.swing.JOptionPane.showMessageDialog(this.getParent(),"时间到!");
                    }
                    catch(InterruptedException e)
                    {                }
            }        public void paint(Graphics g)
            {
              g.drawString(String.valueOf(d),100,100);
            }
    }