java小闹钟代码 java闹钟小程序

跪求高手帮忙写一个JAVA手机闹钟程序 实现添加铃声和设置多闹钟import java.util.*;
import java.awt.*;
import java.applet.*;
import java.text.*;
public class AlarmClock extends Applet implements Runnable
{
Thread timer=null; //创建线程timer
Image clockp,gif1,gif2,clock6,clock7; //clockp:闹钟java小闹钟代码的外壳,闹铃和报时鸟
int s,m,h,hh;
AudioClip ipAu,danger,chirp;
boolean canPaint=true;
boolean flag=false;
boolean strike=true;
int counter=0;
int lasts;
Image offscreen_buf=null;
int i,j,t=0;
int timeout=166;
int lastxs=0,lastys=0,lastxm=0,lastym=0,lastxh=0,lastyh=0;
Date dummy=new Date();//生成Data对象
GregorianCalendar cal=new GregorianCalendar();
SimpleDateFormat df=new SimpleDateFormat("yyyy MM dd HH:mm:ss");//设置时间格式
String lastdate=df.format(dummy);
Font F=new Font("TimesRoman",Font.PLAIN,14);//设置字体格式
Date dat=null;
Date timeNow=null;
Color fgcol=Color.blue;
Color fgcol2=Color.darkGray;
Panel setpanel;
Color backcolor=Color.pink;
TextField showhour,showmin,showsec,sethour,setmin,setsec;//显示当前时间文本框和定时文本框
Button onbutton;
Button offbutton;
Label hlabel1,mlabel1,slabel1,hlabel2,mlabel2,slabel2;//显示时间单位时所用的标签(时、分、秒)
Label info1=new Label("欢迎使用定时提醒闹钟"),info2=new Label("");
Label note1=new Label("当前时间:"),note2=new Label("闹钟设置:");
boolean setalerm=false,clickflag=false;//判断是否响铃和振动
int fixh=0,fixm=0,fixs=0;//记录闹钟的定时
public void init()//初始化方法
{
Integer gif_number;
int fieldx=50,fieldy1=120,fieldy2=220,fieldw=30,fieldh=20,space=50;//显示时间和定时文本框的定位参数
setLayout(null);//将布局管理器初始化为null
setpanel=new Panel();
setpanel.setLayout(null);
setpanel.add(note1);
setpanel.add(note2);
note1.setBounds(30,100,60,20);
note1.setBackground(backcolor);
note1.setForeground(Color.black);
note2.setBounds(30,180,60,20);
note2.setBackground(backcolor);
note2.setForeground(Color.black);
hlabel1=new Label();
mlabel1=new Label();
slabel1=new Label();
hlabel2=new Label();
mlabel2=new Label();
slabel2=new Label();
//显示当前时间用的文本框
showhour=new TextField("00",5);
showmin=new TextField("00",5);
showsec=new TextField("00",5);
//定时用的文本框(时、分、秒)
sethour=new TextField("00",5);
setmin=new TextField("00",5);
setsec=new TextField("00",5);
//当前时间用的文本框的位置、大小
setpanel.add(showhour);
showhour.setBounds(fieldx,fieldy1,fieldw,fieldh);
showhour.setBackground(Color.white);
//在文本框后加入单位“时”
setpanel.add(hlabel1);
hlabel1.setText("时");
hlabel1.setBackground(backcolor);
hlabel1.setForeground(Color.black);
hlabel1.setBounds(fieldx+fieldw+3,fieldy1,14,20);
fieldx=fieldx+space;
//当前时间的分钟文本框的位置、大小
setpanel.add(showmin);
showmin.setBounds(fieldx,fieldy1,fieldw,fieldh);
showmin.setBackground(Color.white);
//在文本框后加入单位“分”
setpanel.add(mlabel1);
mlabel1.setText("分");
mlabel1.setBackground(backcolor);
mlabel1.setForeground(Color.black);
mlabel1.setBounds(fieldx+fieldw+3,fieldy1,14,20);
fieldx=fieldx+space;
//当前时间的秒文本框的位置、大小
setpanel.add(showsec);
showsec.setBounds(fieldx,fieldy1,fieldw,fieldh);
showsec.setBackground(Color.white);
//在文本框后加入单位“秒”
setpanel.add(slabel1);
slabel1.setText("秒");

推荐阅读