import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class GoodLuck extends JFrame implements ActionListener,Runnable
{
static JTextField jf = new JTextField(20);
JButton jb1=new JButton("抽奖");
JButton jb2=new JButton("停止");
JPanel jp=new JPanel();
public GoodLuck()
{
Container con=getContentPane();
jb1.addActionListener(this);
jb2.addActionListener(this);
jb1.setActionCommand("start");
jp.add(jb1);
jp.add(jb2);
con.add(jf,"North");
con.add(jp,"South");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(300,200,400,400);
setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand().equals("start"))
{
Thread t=new Thread();
t.start();
}
}
public static void main(String arg[])
{
new GoodLuck();
}
public void run()
{
for(int i=0;i<10;i++)
{
int num=(int)(Math.random()*36)+1;
if(num<10)
jf.setText("0"+num);
else
jf.setText(""+num);
try
{
Thread.sleep(1000);
}
catch(InterruptedException ex)
{
}
}
}
}