闹钟源代码Java 闹钟java设计代码( 十 )


String color;
Color c;
System.out.println("color5");
color = JOptionPane.showInputDialog(this, "请输入喜欢的秒针颜色(0--255)", "128");
if(color==null){}
else{if (Integer.parseInt(color)0|| Integer.parseInt(color)255)
JOptionPane.showInputDialog(this, "请输入喜欢的秒针颜色(0--255)", "128");
else {
c = new Color(Integer.parseInt(color));
C5 = c;
}
}
}
if(e.getActionCommand() == "color6"){
String color;
Color c;
System.out.println("color6");
color = JOptionPane.showInputDialog(this, "请输入喜欢的分针颜色(0--255)", "128");
if(color==null){}
else{if (Integer.parseInt(color)0|| Integer.parseInt(color)255)
JOptionPane.showInputDialog(this, "请输入喜欢的分针颜色(0--255)", "128");
else {
c = new Color(Integer.parseInt(color));
C6 = c;
}
}
}
if(e.getActionCommand() == "color7"){
String color;
Color c;
System.out.println("color7");
color = JOptionPane.showInputDialog(this, "请输入喜欢的时针颜色(0--255)", "128");
if(color==null){}
else{if (Integer.parseInt(color)0|| Integer.parseInt(color)255)
JOptionPane.showInputDialog(this, "请输入喜欢的时针颜色(0--255)", "128");
else {
c = new Color(Integer.parseInt(color));
C7 = c;
}
}
}
if(e.getActionCommand() == "help"){
String help;
help = JOptionPane.showInputDialog(this, "输入quit退出该闹钟的使用", "这是运行在Java中的指针式时钟");
if(help.equals("quit"))
dispose();
else {}
//timer.restart();
}
}
class SetTime {
【闹钟源代码Java 闹钟java设计代码】String Hour;
String Minute;
public SetTime() { }
public SetTime(int hour, int minute) {
// 当时间参数小于10的时候在前面添加字符0
if (hour10) {
Hour = "0" + String.valueOf(hour);
} else {
Hour = "" + String.valueOf(hour);
}
if (minute10) {
Minute = "0" + String.valueOf(minute);
} else {
Minute = "" + String.valueOf(minute);
}
alarm = Hour + ":" + Minute;
time.setText(alarm);
repaint();
}
}
}
java闹钟程序代码搞不懂为什么要匿名提问,真的那么怕笑话,不至于吧!
import java.util.Timer;
import java.util.Date;
import java.text.SimpleDateFormat;
public class Alarm
{
public static void main(String[] args)
{
Timer timer = new Timer();
try{
timer.schedule(new task(),1000,1000);
}
catch(IllegalStateException e)
{
System.out.println("时间到");
}
}
static class task extends java.util.TimerTask
{
public void run()
{
Date now = new Date();
SimpleDateFormat time = new SimpleDateFormat("HH:mm:ss");
if(time.format(now).toString.equals("23:27:00"))
this.cancel();
else
System.out.println(time.format(now));
}
}
}
请用JAVA编一个闹钟程序,符合要求追加100分!急?。?/h2>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:闹钟的外壳,闹铃和报时鸟
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();

推荐阅读