2011年3月18日 星期五

大樂透



import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class ButtonText extends JFrame implements ActionListener {
 
    public static void main(String[] args) {
    ButtonText test = new ButtonText();
}
ButtonText()
{
    JFrame frame=new JFrame("Button Frame");
   
    JButton button1 = new JButton("Submit");
    JButton button2 = new JButton("Submit");
   
button1.addActionListener(this);
button2.addActionListener(this);
    
getContentPane().add(button1); 
getContentPane().add(button2);
setLayout(new FlowLayout());
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
    setSize(200,100);
    setVisible(true);
  
    
}

public void actionPerformed(ActionEvent e)
{
int ra,rb,rc,rd,re,rf,rg;
ra=(int)(Math.random()*49+1);
rb=(int)(Math.random()*49+1);
rc=(int)(Math.random()*49+1);
rd=(int)(Math.random()*49+1);
re=(int)(Math.random()*49+1);
rf=(int)(Math.random()*49+1);
rg=(int)(Math.random()*49+1);
System.out.println(ra);
System.out.println(rb);
System.out.println(rc);
System.out.println(rd);
System.out.println(re);
System.out.println(rf);
System.out.println(rg);

}

沒有留言:

張貼留言