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 mybutton = new JButton("Submit");
JButton mybutton1 = new JButton("Submit1");
mybutton.addActionListener(this);
getContentPane().add(mybutton);
getContentPane().add(mybutton1);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new FlowLayout());
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(200,100);
setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
int rm1,rm2,rm3,rm4,rm5,rm6,rm7;
rm1 =(int)((Math.random()*49)+1);
rm2 =(int)((Math.random()*49)+1);
rm3 =(int)((Math.random()*49)+1);
rm4 =(int)((Math.random()*49)+1);
rm5 =(int)((Math.random()*49)+1);
rm6 =(int)((Math.random()*49)+1);
rm7 =(int)((Math.random()*49)+1);
System.out.println(rm1);
System.out.println(rm2);
System.out.println(rm3);
System.out.println(rm4);
System.out.println(rm5);
System.out.println(rm6);
System.out.println(rm7);
}
}
沒有留言:
張貼留言