作者g4530 (新手上路^^)
看板java
标题[问题] 关於JAVA的util套件
时间Mon Nov 17 20:55:17 2008
各位学长姊好
在下在练习作业的时候出了一点小trouble
情况如下
我在自己的电脑会无法找到util的方法
导致无法顺利compile 档案
但是传给其他同学测试就ok 而且也可以正常执行
JDK也重灌过
但仍是无法解决
希望可以帮忙解答一下
感谢大家^^
--
附上程式码
import java.awt.*;
import javax.swing.*;
import java.util.*;
import java.text.*;
public class ClockThread implements Runnable{
Thread t ;
JLabel l ;
public ClockThread(){
JFrame f = new JFrame("test");
f.setBounds(150,250,150,100);
f.setLayout(new BorderLayout());
l = new JLabel();
l.setFont(new Font("",Font.BOLD,30));
f.add(l,"Center");
f.setVisible(true);
t = new Thread(this);
t.start();
}
public void run(){
while(true){
try{
System.out.print("1");
l.setText(getTime());
Thread.sleep(1000);
}catch(InterruptedException e){}
}
}
public String getTime(){
String a;
Calendar c = Calendar.getInstance();
int n = c.get(Calendar.AM_PM);
if(n==0)
a = " AM" ;
else
a = " PM" ;
return
c.get(Calendar.HOUR)+":"+c.get(Calendar.MINUTE)+":"+c.get(Calendar.SECOND)
+""+a;
}
public static void main(String[] args){
new ClockThread();
}
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.115.236.21
1F:推 ogamenewbie:知道 classpath 嘛? 以及 classpath 的设定状况? 11/17 21:22
2F:推 rick1014:把CLASSPATH设定好,应该就ok了..... 11/18 01:39
3F:→ g4530:感谢两位 我是照书上设定的@@a 其他套件使用上就没问题说^^ 11/18 09:50
4F:→ g4530:结果 直接汇入Calendar就好了 用*号反而不行 =__=||| 11/18 14:37