谁有抽奖类的源码啊?主要想要数字的滚动效果 (数字从1-200)

解决方案 »

  1.   

    你说的是要从1-200中取一个随机数么?
    Random r = new Random();
    int randomInt = r.nextInt(200);
      

  2.   

    int r=(int)(Math.random()*200+1);
      

  3.   

    产生1到200之间的随机数的程序class abcd1{
    public static void main(String[]args)
    {
    int a =(int)(Math.random()*199+1);
    System.out.println(a);
    }
    }
      

  4.   

    import java.util.*;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    public class CountInstances extends JFrame implements ActionListener{
    private JLabel jla = new JLabel("中奖号码:");
    private JButton jba = new JButton("开始");
    private JButton jbb = new JButton("停止");
    private static boolean flag = true;
    public CountInstances(){
    this.setLayout(null);
    this.add(jla);
    jla.setFont(new Font("Courier",Font.PLAIN,22));
    jla.setHorizontalAlignment(JLabel.CENTER);
      jla.setVerticalAlignment(JLabel.CENTER); 
      jla.setBounds(100,100,180,30);
     
      this.add(jba);this.add(jbb);
      jba.setBounds(75,150,80,26);
      jbb.setBounds(200,150,80,26);
      jba.addActionListener(this);
      jbb.addActionListener(this);
      this.setTitle("抽奖程序");
    this.setBounds(400,400,400,300);
    this.setVisible(true);
    }
    public void actionPerformed(ActionEvent e){
    if(e.getSource()==jba){
    new Thread(){
    public void run(){
    while(CountInstances.flag){
    Random r = new Random(); 
    int randomInt = r.nextInt(200);
    jla.setText("中奖号码:"+randomInt);
    }
    }
    }.start();
    }
    else if(e.getSource()==jbb){
    flag = false;
    }
    }
        public static void main(String arguments []){ 
    new CountInstances();
        }
    }写的不好
      

  5.   

    import java.util.*;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    public class CountInstances extends JFrame implements ActionListener{
    private JLabel jla = new JLabel("中奖号码:");
    private JLabel jlb = new JLabel();
    private JButton jba = new JButton("开始");
    private JButton jbb = new JButton("停止");
    private static boolean flag = true;
    public CountInstances(){
    this.setLayout(null);
    this.add(jla);this.add(jlb);
    jla.setFont(new Font("Courier",Font.PLAIN,22));
    jla.setHorizontalAlignment(JLabel.CENTER);
      jla.setVerticalAlignment(JLabel.CENTER); 
      jla.setBounds(100,100,180,30);
     
      jlb.setFont(new Font("Courier",Font.PLAIN,22));
    jlb.setHorizontalAlignment(JLabel.CENTER);
      jlb.setVerticalAlignment(JLabel.CENTER); 
      jlb.setBounds(160,100,180,30);
     
      this.add(jba);this.add(jbb);
      jba.setBounds(75,150,80,26);
      jbb.setBounds(200,150,80,26);
      jba.addActionListener(this);
      jbb.addActionListener(this);
      this.setTitle("抽奖程序");
    this.setBounds(400,400,400,300);
    this.setVisible(true);
    }
    public void actionPerformed(ActionEvent e){
    if(e.getSource()==jba){
    flag = true;
    new Thread(){
    public void run(){
    while(CountInstances.flag){
    Random r = new Random(); 
    int randomInt = r.nextInt(200);
    jlb.setText(""+randomInt);
    }
    }
    }.start();
    }
    else if(e.getSource()==jbb){
    flag = false;
    }
    }
        public static void main(String arguments []){ 
    new CountInstances();
        }
    }改了下 呵呵
      

  6.   

    这个是JS的,不是java的,呵呵
    数字滚动抽奖的代码下面这个是我根据8楼代码整理并转载的,
    一段抽奖的模拟代码,图形界面,开始和结束按钮,随机产生中奖数字
    加上了运行效果