我写了一个关于“电子表”的Java程序,但是显示不出来
来源:百度知道 编辑:UC知道 时间:2024/06/24 10:56:57
源程序如下:import java.awt.*;
import java.awt.event.*;
import java.text.SimpleDateFormat;
import java.util.*;
public class Watch extends Frame{
TextField tf = new TextField();
Date d;
String st;
public static void main(String[] args) {
new Watch().launchFrame();
}
public void launchFrame(){
this.setSize(40, 120);
this.setLocation(300,300);
this.setTitle("电子表");
new Thread(new DateThread()).start();
add(tf);
tf.setText(st);
pack();
this.setVisible(true);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent g) {
System.exit(0);
}
});
}
class DateThread implements Runnable {
SimpleDateFormat sdf = new SimpleDateFormat
import java.awt.*;
import java.awt.event.*;
import java.text.SimpleDateFormat;
import java.util.*;
public class Watch extends Frame {
private static final long serialVersionUID = 1L;
TextField tf = new TextField();
Date d;
String st;
public static void main(String[] args) {
new Watch().launchFrame();
}
public void launchFrame() {
this.setSize(40, 120);
this.setLocation(300, 300);
this.setTitle("电子表");
new DateThread().start();
add(tf);
System.err.println(st);
pack();
this.setVisible(true);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent g) {
System.exit(0);
}
});
}
class DateThread extends Thread {
SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss");
public void run(