如何加入鬧鐘 |
尚未結案
|
man13579
一般會員 發表:3 回覆:1 積分:0 註冊:2004-12-02 發送簡訊給我 |
底下為一個鬧鐘程式,想請問該如何才能讓它具有鬧鐘的功能呢?
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.awt.image.ImageObserver;
import java.util.*;
import javax.swing.*;
import java.applet.*; public class P0602 extends JFrame
implements Runnable,ActionListener
{ // 圖框大小
Dimension FS=new Dimension(800,600);
// 圖框中央的座標
Point FC=new Point(FS.width/2,FS.height/2);
String[]str={"啟動","鬧鐘啟動"};//鬧鐘啟動尚未定義
JButton[]bt=new JButton[str.length];
JTextField tf1=new JTextField("",5);//準備給鬧鐘設定小時用
JTextField tf2=new JTextField("",5);//準備給鬧鐘設定分鐘用
Thread th=null;
TimeZone tz=TimeZone.getTimeZone("GMT+08:00");
Image Im;
Graphics2D G,ImG;
int r=240; public P0602(String title)
{ super(title);
setSize(FS);
setBackground(Color.blue);
Container cp=getContentPane();
cp.setBackground(getBackground());
cp.setLayout(new FlowLayout(FlowLayout.LEFT));
for(int i=0;i
|
ahan
一般會員 發表:11 回覆:18 積分:15 註冊:2002-07-07 發送簡訊給我 |
|
neoart
版主 發表:22 回覆:582 積分:425 註冊:2003-05-09 發送簡訊給我 |
你既然有指針繪出的功能了,那就在其繪出的函數(my_paint)中比對你設定的鬧鐘時間,再決定是不是要pop out一個訊息.
要不,就在你的my_paint的時間比對之後,加入一個撥放音效的功能.
時間比對方面,可以考慮用text format物件:
SimpleDateFormat sf=new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); String currentTimeString=sf.format( new java.sql.Date(System.currentTimeMillis())); if(currentTimeString.equals("2004/12/20 14:00:00")){ /***IT'S SHOW TIME!! BOOOOOOOOOOMMMMMMM ***/ }想要來點音效嗎?參考: java.applet.AudioClip類別: http://java.sun.com/docs/books/tutorial/sound/playing.html |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |