资源简介
闹钟java源码,闹钟java源码,闹钟java源码,闹钟java源码,闹钟java源码,闹钟java源码,闹钟java源码
代码片段和文件信息
package alarmclock;
import java.awt.Component;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.text.ParseException;
import java.util.Date;
import java.util.Formatter;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.Jframe;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import sun.audio.AudioPlayer;
import sun.audio.AudioStream;
public class alarmClock {
JLabel Label[];
ButtonGroup BtnGroup;
JRadioButton intervalRadiospecifyRadio;
JTextField minuteTexttimeText;
JCheckBox chkBox;
JButton OKBtnCancleBtn;
Container con;
GridBagLayout gridBag;
Jframe mainJframe;
Date today;
Timer myTimer;
int remainSeconds = 0;
boolean startTime = false;
private void addComponents(Component objGridBagConstraints c){
gridBag.setConstraints(obj c);
con.add(obj);
}
//将时间转换成为“时:分:秒”格式的字符串
private String TimeToString(Date day){
Formatter fmt = new Formatter();
fmt.format(“%tT“ day);
return fmt.toString();
}
private int parseTime(String str) throws ParseException {
int i=0hour=0minute=0second=0;
int ch;
ch = str.charAt(i);
while(i if(ch<‘0‘||ch>‘9‘)
throw new ParseException(stri);
hour = hour*10 + ch - ‘0‘;
i++;
if(i ch=str.charAt(i);
else
throw new ParseException(stri);
}
i++;
ch = str.charAt(i);
while(i if(ch<‘0‘||ch>‘9‘)
throw new ParseException(stri);
minute = minute*10 + ch - ‘0‘;
i++;
if(i ch = str.charAt(i);
else
throw new ParseException(stri);
}
i++;
ch = str.charAt(i);
while(i if(ch<‘0‘ || ch>‘9‘)
throw new ParseException(stri);
second = second*10 + ch - ‘0‘;
i++;
if(i ch = str.charAt(i);
}
if(hour>23 || minute>59 ||second>59)
throw new ParseException(stri);
return hour*3600 + minute*60 +second;
}
public alarmClock(){
final String msg[] = {
“当前时间““““订于““分钟后““订于““提醒““现在还差““ 0 秒“
};
Refresh task;
HandleBtn handl = new HandleBtn();
GridBagConstraints c = new GridBagConstraints();
Label = new JLabel[msg.length];
for(int i=0;i Label[i] = new JLabel(msg[i]JLabel.CENTER);
mainJframe = new Jframe(“小闹钟“);
today = new Date();
gridBag = new GridBagLayout();
con = mainJframe.getContentPane();
con.setLayout(gridBag);
c.fill = GridBagConstrai
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2011-07-18 20:56 AlarmClockOnlyOne\
文件 232 2011-07-18 20:56 AlarmClockOnlyOne\.classpath
文件 393 2011-07-18 20:56 AlarmClockOnlyOne\.project
目录 0 2011-07-18 20:57 AlarmClockOnlyOne\bin\
目录 0 2011-07-18 23:34 AlarmClockOnlyOne\bin\alarmclock\
文件 2701 2011-07-18 23:37 AlarmClockOnlyOne\bin\alarmclock\alarmClock$HandleBtn.class
文件 1853 2011-07-18 23:37 AlarmClockOnlyOne\bin\alarmclock\alarmClock$Refresh.class
文件 3189 2011-07-18 23:37 AlarmClockOnlyOne\bin\alarmclock\alarmClock.class
目录 0 2011-07-18 20:57 AlarmClockOnlyOne\src\
目录 0 2011-07-18 20:57 AlarmClockOnlyOne\src\alarmclock\
文件 7133 2011-07-18 23:37 AlarmClockOnlyOne\src\alarmclock\alarmClock.java
评论
共有 条评论