2011年3月18日 星期五

2011/03/18 隨機7個樂透號碼

跑程式
做修改

做兩個BUTTOM

跑範例


作業 隨機7個樂透號碼
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class ButtonText extends JFrame implements ActionListener  {
  public static void main(String[] args) {
ButtonText test = new ButtonText ();
 }

 ButtonText()
  {  
JButton mybutton1 = new JButton("Submit");
JButton mybutton2 = new JButton("Submit");
mybutton1.addActionListener(this);
//Container contentPane = frame.getContentPane();
//contentPane.add(mybutton1);
//contentPane.add(mybutton2);
getContentPane().add(mybutton1);
getContentPane().add(mybutton2);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new FlowLayout());
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(200,100);
setVisible(true);
    //System.out.println("wait");
    //System.exit(0);
  
    }
public void actionPerformed(ActionEvent e) {
int rn,rb,rc,rd,re,rf,rg;
 rn=(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(rn );
System.out.println(rb );
System.out.println(rc );
System.out.println(rd );
System.out.println(re );
System.out.println(rf );
System.out.println(rg );
}
}




沒有留言:

張貼留言

Use google protocol buffers + QT +CMAKE

Protocol Buffers https://developers.google.com/protocol-buffers/ Serialize and ParseFrom https://www.jianshu....