u013176244 于 2015.06.21 21:38 提问
- 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
}
}
-
-
-
danielinbiti
2015.06.21 21:52
- 已采纳
@param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here
TextTime tt = new TextTime();
tt.start();
}
}
-
- u013176244 回复danielinbiti:我是用NetBean8.0.1
- 接近 3 年之前 回复
-
- danielinbiti 回复爱学习的东方人: 给你试了一下,用eclipse,选择run applet,能运行出界面,文本框也能出现,也能更新。你自己再检查检查环境
- 接近 3 年之前 回复
-
- u013176244 实例化对象试过了,没有出现文本框
- 接近 3 年之前 回复
-
- tongyi55555 2015.06.22 09:16
什么问题也没有描述啊???
-
- u013176244 这段代码是教材上的,在主函数代码块中没有任何代码,不知道怎么运行它
- 接近 3 年之前 回复
-
- tongyi55555 2015.06.23 09:45
把下面的代码放到主函数中,然后在Eclipse右击选择Run As -->Java Applet即可看到结果了。
TextTime textTime = new TextTime();
textTime.start();
如果你想在CMD或者IE中查看,请参考下面的内容:
http://developer.51cto.com/art/201203/325976.htm
-
- tongyi55555 回复爱学习的东方人: 怎么会呢?你显示的日期时间不就是在文本框么?只不过你的内容1秒更新一次
- 接近 3 年之前 回复
-
- u013176244 实例化对象试过了,没有出现文本框
- 接近 3 年之前 回复
-
- u013176244 实例化对象试过了,没有出现文本框
- 接近 3 年之前 回复
-
- u013176244 实例化对象试过了,没有出现文本框
- 接近 3 年之前 回复
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!