62,614
社区成员
发帖
与我相关
我的任务
分享
public class Test implements Runnable {
private JFrame frame = null;
private JLabel label = null;
private int count = 0;
public Test() {
frame = new JFrame("test");
label = new JLabel("0");
frame.add(label);
frame.setSize(500, 400);
frame.setVisible(true);
}
public void run() {
try {
while (true) {
Thread.sleep(5000);
label.setText(String.valueOf(++count));
label.updateUI();
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
public static void main(String[] args) throws Exception {
Test test = new Test();
new Thread(test).start();
}
}