问题描述
- java文字时钟运行问题
-
package texttime;
import java.applet.*;
import java.util.*;
import java.awt.*;/**
*- @author Administrator
*/
public class TextTime extends Applet implements Runnable {
Thread th=null;
TextField tt=new TextField(30);
public void init(){
add(tt);
}
public void start(){
if(th==null){
th=new Thread(this);
th.start();
}
}
public void stop(){
if(th!=null){
th.stop();
th=null;
}
}
public void run(){
while(true){
Date dd=new Date();
tt.setText(dd.toGMTString());
try{
Thread.sleep(1000);
}catch(InterruptedException e){
}
}
}/**
- @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
}
- @param args the command line arguments
}
- @author Administrator
解决方案
@param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here
TextTime tt = new TextTime();
tt.start();
}
}
解决方案二:
什么问题也没有描述啊???
解决方案三:
把下面的代码放到主函数中,然后在Eclipse右击选择Run As -->Java Applet即可看到结果了。
TextTime textTime = new TextTime();
textTime.start();
如果你想在CMD或者IE中查看,请参考下面的内容:
http://developer.51cto.com/art/201203/325976.htm
时间: 2024-11-18 08:31:20