Swing下,我在Frame下面加入一个状态栏,就是ToolBar, 怎么在其中动态的时间?另外,我在网上搜到一个示例代码,里面有行有错为什么:
public class DisplayDate implements Runnable {
private Thread aThread = null;
private Date date = new Date();
public static void main(String args[]) {
DisplayDate displaydate = new DisplayDate();
displaydate.StartDisplay(); } public void StartDisplay() {
aThread = Thread(this); // 这里要报错,好像意思是没有这个方法。
aThread.start();
} public void run() {
while (true) {
try {
//Add your display time code here; Thread.sleep(1000); } catch (Exception e) {
} }
}}
public class DisplayDate implements Runnable {
private Thread aThread = null;
private Date date = new Date();
public static void main(String args[]) {
DisplayDate displaydate = new DisplayDate();
displaydate.StartDisplay(); } public void StartDisplay() {
aThread = Thread(this); // 这里要报错,好像意思是没有这个方法。
aThread.start();
} public void run() {
while (true) {
try {
//Add your display time code here; Thread.sleep(1000); } catch (Exception e) {
} }
}}
注意上面的new操作,这样就没有报错了