当前位置: 代码迷 >> Java相关 >> 彩票系统怎么弄 新人 求解!!!!!!!!!
  详细解决方案

彩票系统怎么弄 新人 求解!!!!!!!!!

热度:444   发布时间:2012-12-06 23:18:35.0
彩票系统怎么弄 新人 求解!!!!!!!!!
求大仙给个用JAVA编的彩票系统
搜索更多相关的解决方案: 彩票  系统  JAVA  

----------------解决方案--------------------------------------------------------
import java.awt.*;
import java.awt.event.*;
/*import java.awt.event.ActionListener;
*/
import javax.swing.*;
/*import javax.swing.JFrame;
import javax.swing.JLabel;
*/

public class CaiPiao extends JFrame{
JLabel[] lblNum=new JLabel[6];
JButton btnStart=new JButton("开始");
JButton btnEnd=new JButton("停止");
ShowNum[] th=null;
public static boolean flag=true;
private void init(){
    setLayout(new FlowLayout());
    for(int i=0;i<6;i++){
        lblNum[i]=new JLabel();
        add(lblNum[i]);
        lblNum[i].setText("0");
        
    }
    add(btnStart);add(btnEnd);
    this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    btnStart.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent ae){
            th=new ShowNum[6];
            for(int i=0;i<6;i++){
                th[i]=new ShowNum(lblNum[i]);
                //th[i].SetFlag(true);
                CaiPiao.flag=true;
                th[i].start();
            }
        }
    });
    btnEnd.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent ae){
            for(int i=0;i<6;i++){
                //th[i].SetFlag(false);
                CaiPiao.flag=false;
            }
        }
    });
}
public CaiPiao(){
    super("体育彩票");
    init();
    this.setSize(450,500);
    this.setVisible(true);
}
public static void main(String args[]){
    CaiPiao cp=new CaiPiao();
}
class ShowNum extends Thread{
    private JLabel lblNum=null;
    boolean flag=true;
    public ShowNum(JLabel lblNum){
        this.lblNum=lblNum;
    }
    public void SetFlag(boolean flag){
        this.flag=flag;
    }
    public void run(){
        while(CaiPiao.flag){
            int a=(int)(Math.random()*10);
            lblNum.setText(String.valueOf(a));
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
            
                e.printStackTrace();
            }
        }
    }
}
}


    希望可以帮到你!
----------------解决方案--------------------------------------------------------
k
----------------解决方案--------------------------------------------------------
  相关解决方案