import java.util.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.applet.*;
import java.text.*;
import javax.swing.JFrame;
public class AlarmClock extends JFrame
{
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("秒");
slabel1.setBackground(backcolor);
slabel1.setForeground(Color.black);
slabel1.setBounds(fieldx+fieldw+3,fieldy1,14,20);
fieldx=50;
//定时的小时文本框的位置、大小
setpanel.add(sethour);
sethour.setBounds(fieldx,fieldy2,fieldw,fieldh);
sethour.setBackground(Color.white);
//在文本框后加入单位"时"
setpanel.add(hlabel2);
hlabel2.setText("时");
hlabel2.setBackground(backcolor);
hlabel2.setForeground(Color.black);
hlabel2.setBounds(fieldx+fieldw+3,fieldy2,14,20);
fieldx=fieldx+space;
//定时的分钟文本框的位置、大小
setpanel.add(setmin);
setmin.setBounds(fieldx,fieldy2,fieldw,fieldh);
setmin.setBackground(Color.white);
//在文本框后加入单位"分"
setpanel.add(mlabel2);
mlabel2.setText("分");
mlabel2.setBackground(backcolor);
mlabel2.setForeground(Color.black);
mlabel2.setBounds(fieldx+fieldw+3,fieldy2,14,20);
fieldx=fieldx+space;
//定时的秒文本框的位置、大小
setpanel.add(setsec);
setsec.setBounds(fieldx,fieldy2,fieldw,fieldh);
setsec.setBackground(Color.white);
//在文本框后加入单位"秒"
setpanel.add(slabel2);
slabel2.setText("秒");
slabel2.setBackground(backcolor);
slabel2.setForeground(Color.black);
slabel2.setBounds(fieldx+fieldw+3,fieldy2,14,20);
//设置闹钟控制按钮(on,off)
onbutton=new Button("开");
offbutton=new Button("关");
setpanel.add(onbutton);
setpanel.add(offbutton);
onbutton.setBounds(90,180,40,20);
offbutton.setBounds(140,180,40,20);
//加入一些附加的信息标签(题头,题尾)
setpanel.add(info1);
info1.setBackground(backcolor);
info1.setForeground(Color.blue);
info1.setBounds(50,50,150,20);
setpanel.add(info2);
info2.setBackground(backcolor);
info2.setForeground(Color.blue);
info2.setBounds(150,280,100,20);
//将面板加入当前容器中,并设置面板的大小及背景色
add(setpanel);
setpanel.setBounds(300,1,250,420);
setpanel.setBackground(backcolor);
setVisible(true);
}}
//////////////////////////////////////////////////////////////////////
public class ss {
public static void main(String[] args) {
AlarmClock ZZ= new AlarmClock();
}
}