package zuoye;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Calendar;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class Daoxu extends JFrame {
int count;
String[] m = null;
int[]sum = null;
boolean flag = true;
JPanel panel = null;
JTextField text = null;
JButton button1 = null;
MyThread thread = null;
Thread t = null;
Daoxu(){
init();
this.setTitle("倒计时");
this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
this.pack();
this.setVisible(true);
}
void init(){
panel = new JPanel();
text = new JTextField(10);
MyAction e =new MyAction();
button1 = new JButton("倒计时开始");
button1.addActionListener(e);
thread = new MyThread();
t = new Thread(thread);
panel.add(text);
panel.add(button1);
this.add(panel);
}
class MyThread implements Runnable{
@Override
public void run() {
// TODO Auto-generated method stub
try {
while(true){
sum[1]--;
Thread.sleep(1);
}
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
class MyAction implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource() == button1)
{
m = text.getText().split(":");
sum = new int[3];
for(int i = 0;i
package zuoye;
public class DemoForDaoxu {
/**
* @param args
*/
public static void main(String[] args) {
new Daoxu();
}
}