java做的一个时钟的小程序
来源:互联网 发布:涉密软件开发 编辑:程序博客网 时间:2024/05/06 03:22
import java.applet.*;
import java.awt.*;
import java.util.Calendar;
public class Clock extends Applet implements Runnable
{
// private int xi,yi;
//private int r;
Calendar t;
Thread t1;
private int s,m,h;
public void init()
{
}
public void paint(Graphics g)
{
g.setColor(Color.red);
g.drawOval(50,50,100,100);
g.setColor(Color.black);
g.fillOval(50,50,102,102);
g.setColor(Color.blue);
g.drawOval(48,48,105,105);
g.drawOval(105,105,5,5);
g.drawString("12",97,65);
g.drawLine(100,50,100,55);
g.drawString("3",140,100);
g.drawLine(150,100,145,100);
g.drawString("6",100,140);
g.drawLine(100,150,100,145);
g.drawString("9",60,100);
g.drawLine(50,100,55,100);
g.setColor(Color.blue);
t=Calendar.getInstance();
s=t.get(Calendar.SECOND);
m=t.get(Calendar.MINUTE);
h=t.get(Calendar.HOUR);
g.setColor(Color.green);
g.drawLine(105,105,105+(int)(40*Math.sin(2*s*Math.PI/60)),105-(int)(40*Math.cos(2*s*Math.PI/60)));
g.setColor(Color.yellow);
g.drawLine(105,105,105+(int)(30*Math.sin(2*m*Math.PI/60)),105-(int)(30*Math.cos(2*m*Math.PI/60)));
g.setColor(Color.red);
g.drawLine(105,105,105+(int)(20*Math.sin((h*5+m/12)*2*Math.PI/60)),105-(int)(20*Math.cos((h*5+m/12)*2*Math.PI/60)));
g.drawString("现在的时间是:"+h+":"+m+":"+s,150,150);
}
public void run()
{
while(true)
{
try
{
repaint();
Thread.sleep(1000);
}
catch (Exception e)
{
}
}
}
public void start()
{
t1=new Thread(this);
t1.start();
}
}
import java.awt.*;
import java.util.Calendar;
public class Clock extends Applet implements Runnable
{
// private int xi,yi;
//private int r;
Calendar t;
Thread t1;
private int s,m,h;
public void init()
{
}
public void paint(Graphics g)
{
g.setColor(Color.red);
g.drawOval(50,50,100,100);
g.setColor(Color.black);
g.fillOval(50,50,102,102);
g.setColor(Color.blue);
g.drawOval(48,48,105,105);
g.drawOval(105,105,5,5);
g.drawString("12",97,65);
g.drawLine(100,50,100,55);
g.drawString("3",140,100);
g.drawLine(150,100,145,100);
g.drawString("6",100,140);
g.drawLine(100,150,100,145);
g.drawString("9",60,100);
g.drawLine(50,100,55,100);
g.setColor(Color.blue);
t=Calendar.getInstance();
s=t.get(Calendar.SECOND);
m=t.get(Calendar.MINUTE);
h=t.get(Calendar.HOUR);
g.setColor(Color.green);
g.drawLine(105,105,105+(int)(40*Math.sin(2*s*Math.PI/60)),105-(int)(40*Math.cos(2*s*Math.PI/60)));
g.setColor(Color.yellow);
g.drawLine(105,105,105+(int)(30*Math.sin(2*m*Math.PI/60)),105-(int)(30*Math.cos(2*m*Math.PI/60)));
g.setColor(Color.red);
g.drawLine(105,105,105+(int)(20*Math.sin((h*5+m/12)*2*Math.PI/60)),105-(int)(20*Math.cos((h*5+m/12)*2*Math.PI/60)));
g.drawString("现在的时间是:"+h+":"+m+":"+s,150,150);
}
public void run()
{
while(true)
{
try
{
repaint();
Thread.sleep(1000);
}
catch (Exception e)
{
}
}
}
public void start()
{
t1=new Thread(this);
t1.start();
}
}
- java做的一个时钟的小程序
- java写一个Swing小程序:《我的时钟》
- 关于时钟的一个小程序
- 用JAVA做一个时钟程序
- 一个小时钟程序
- 用VB做的一个小程序
- JavaScript的时钟小程序
- java的一个小程序
- Java的一个小程序
- 树莓派3做的OLED小时钟
- java实现一个小的时钟(当前时间)
- 怎样用Java写一个动态的小时钟?
- flash做一个时钟程序
- java小程序:小时钟
- 用C做的电子时钟程序
- 一个经典的JAVA APPLET时钟程序(一)
- 一个经典的JAVA APPLET时钟程序(一)
- 用javascript做的一个背景时钟
- 心态决定命运
- 识破欺骗 教你简单方法查找黑客老巢
- Symbain S60 入门之旅, HelloCarbide example
- 五一记
- google搜索原理论文
- java做的一个时钟的小程序
- 五月十一日
- 一个权限设计教程
- [转]几种正规表达式
- SQLServer取特定记录
- 分析师:微软今年内收购雅虎的十个理由
- SAP Notes---BW
- C++ UNICODE 编程从入门到精通
- C# 应用程序控件 放到最上层。