如何让时间停下来

来源:百度知道 编辑:UC知道 时间:2024/06/02 07:09:00
import java.util.Date;
import java.awt.*;
import java.awt.event.*;
public class ShowSeconds extends Frame implements Runnable
{ private Thread clocker = null;
private Date now = new Date();
private Button stop = new Button("stop");
private Label label = new Label();
private boolean flag=true;
public ShowSeconds()
{ clocker = new Thread(this);
clocker.start();
Panel bottom = new Panel();
bottom.setLayout(new FlowLayout( ));
bottom.add(stop);
setLayout(new BorderLayout());
add("Center",label);
add("South",bottom);
addWindowListener(new WindowAdapter()
{ public void windowClosing(WindowEvent we)
{ System.exit(0); }
});
pack(); show();
}
public void run()
{
Thread currentThread = Thread.currentThread();
while (fl

package 娱乐;

import java.util.Date;
import java.awt.*;
import java.awt.event.*;

public class 时间 extends Frame implements Runnable {
private Thread clocker = null;

private Date now = new Date();

private Button stop = new Button("stop");

private Label label = new Label();

private boolean flag = true;

public 时间() {
clocker = new Thread(this);
clocker.start();
Panel bottom = new Panel();
bottom.setLayout(new FlowLayout());
bottom.add(stop);
setLayout(new BorderLayout());
add("Center", label);
add("South", bottom);
stop.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
stop();
}
});
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
System.exit(0);
}
});
pa