Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package smcm.edu.COSC130;
- import java.awt.BorderLayout;
- import java.awt.GridLayout;
- import javax.swing.JFrame;
- import javax.swing.JOptionPane;
- import javax.swing.JTextField;
- import javax.swing.JPanel;
- import javax.swing.JButton;
- import smcm.edu.COSC130.FunWithGUI.EventHandler;
- import java.util.Random;
- import java.awt.Event;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- public class Bingo extends JFrame {
- public Bingo(){
- super("Bingo");
- setLayout(new BorderLayout());
- Random z = new Random();
- int b=0;
- String [][] buttonText = new String [5][5];
- String[][] actions = new String [1][2];
- actions [0][1]= "Next Ball";
- actions [0][2]= "Bingo!";
- buttonText[2][2]= "Free";
- for(int i=0; i<5; i++){
- for(int j=0; j<5; j++){
- if (j==0){
- b = z.nextInt(15)+1;
- buttonText[i][j]=Integer.toString(b);
- }else if (j==1){
- b= z.nextInt(15)+16 ;
- buttonText[i][j]=Integer.toString(b);
- }else if (j==2){
- b = z.nextInt(15)+31;
- buttonText[i][j]=Integer.toString(b);
- }else if (j==3){
- b = z.nextInt(15)+46;
- buttonText[i][j]=Integer.toString(b);
- }else if(j==4){
- b = z.nextInt(15)+61;
- buttonText[i][j]=Integer.toString(b);
- }
- }
- }
- JPanel buttons = new JPanel();
- buttons.setLayout(new GridLayout(5,5));
- JButton[][] button = new JButton [5][5];
- for(int i=0; i<5; i++){
- for(int j=0; j<5; j++){
- button[i][j] = new JButton(buttonText[i][j]);
- buttons.add(button[i][j]);
- }
- }
- JPanel actions1 = new JPanel();
- actions1.setLayout(new GridLayout(2,1));
- JButton[][] act = new JButton[2][1];
- for(int i=0; i<2; i++){
- for (int j=0; j<1; j++){
- act[i][j] = new JButton(actions[i][j]);
- buttons.add(button[i][j]);
- }
- }
- add(buttons, BorderLayout.NORTH);
- add(buttons, BorderLayout.CENTER);
- EventHandler eh = new EventHandler();
- //buttonText.addActionListener(eh);
- }
- public class EventHandler implements ActionListener{
- public void actionPerformed(ActionEvent e){
- if(e.getSource()== buttonText){
- }
- }
- }
- int count=-1;
- String [] numCalled = new String[200];//keeps track of numbers called
- //random number for new ball
- public void randNum(){
- Random r = new Random();
- int randvalue = r.nextInt(75)+1;
- count++;
- numCalled[count]= Integer.toString(randvalue);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement