当前位置: 代码迷 >> Java相关 >> [求助]这个程序要怎么写??
  详细解决方案

[求助]这个程序要怎么写??

热度:202   发布时间:2006-06-19 12:52:18.0
[求助]这个程序要怎么写??
编写一个Applet,动画显示一个数码钟,用数字显示时、分、秒.

尽快就要了,高手请教下..
谢谢了
搜索更多相关的解决方案: 动画  数码  

----------------解决方案--------------------------------------------------------
请搜索本论坛,有此方面的实例
不过还是建议能够自己编码
----------------解决方案--------------------------------------------------------
如果是新手,先学点基础,我学了一两个月基础了,但是对JAVA还是了解一下部分
----------------解决方案--------------------------------------------------------

谁都不能说他对JAVA很了解,JAVA实在是太大了
根本不可能完全掌握的
我们只求学会一部分就够了


----------------解决方案--------------------------------------------------------

这个程序是我以前写的 你改成APPLET就行了

import java.util.*;
import java.awt.*;
import java.text.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
class ClockPanel extends JPanel implements Runnable{
Thread th=null;
String today;
Date date=null;
GregorianCalendar cal=new GregorianCalendar();
SimpleDateFormat df=new SimpleDateFormat("yyyy MM dd HH:mm:ss");
public ClockPanel(){
th=new Thread(this);
th.start();
}
public void run(){
while(th!=null){
repaint();
try{
Thread.sleep(500);
}catch(InterruptedException e){}
}
}
public void paintComponent(Graphics g){
super.paintComponent(g);
date=new Date();
cal.setTime(date);
today=df.format(date);
g.drawString(today,80,80);
}
}
class ClockFrame extends JFrame{
public ClockFrame(){
Container con=getContentPane();
ClockPanel p=new ClockPanel();
setTitle("clock");
setSize(300,200);
setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
con.add(p);
}

}
public class MyClock{
public static void main(String args[]){
ClockFrame f=new ClockFrame();
f.setVisible(true);
}
}


----------------解决方案--------------------------------------------------------
支持一下,也希望大家都能把自己的东西共享出来
大家一起进步

----------------解决方案--------------------------------------------------------
非常感谢了!!

其实对JAVA我不感兴趣只是这是期末的作业不得去做了

现在终于可以上交作业了!!!
----------------解决方案--------------------------------------------------------
  相关解决方案