Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. package smcm.edu.COSC130;
  2. import java.awt.BorderLayout;
  3. import java.awt.GridLayout;
  4.  
  5. import javax.swing.JFrame;
  6. import javax.swing.JOptionPane;
  7. import javax.swing.JTextField;
  8. import javax.swing.JPanel;
  9. import javax.swing.JButton;
  10.  
  11. import smcm.edu.COSC130.FunWithGUI.EventHandler;
  12.  
  13. import java.util.Random;
  14.  
  15. import java.awt.Event;
  16. import java.awt.event.ActionEvent;
  17. import java.awt.event.ActionListener;
  18.  
  19. public class Bingo extends JFrame {
  20.  
  21. public Bingo(){
  22. super("Bingo");
  23. setLayout(new BorderLayout());
  24.  
  25. Random z = new Random();
  26. int b=0;
  27. String [][] buttonText = new String [5][5];
  28. String[][] actions = new String [1][2];
  29. actions [0][1]= "Next Ball";
  30. actions [0][2]= "Bingo!";
  31. buttonText[2][2]= "Free";
  32.  
  33. for(int i=0; i<5; i++){
  34. for(int j=0; j<5; j++){
  35. if (j==0){
  36. b = z.nextInt(15)+1;
  37. buttonText[i][j]=Integer.toString(b);
  38. }else if (j==1){
  39. b= z.nextInt(15)+16 ;
  40. buttonText[i][j]=Integer.toString(b);
  41. }else if (j==2){
  42. b = z.nextInt(15)+31;
  43. buttonText[i][j]=Integer.toString(b);
  44. }else if (j==3){
  45. b = z.nextInt(15)+46;
  46. buttonText[i][j]=Integer.toString(b);
  47. }else if(j==4){
  48. b = z.nextInt(15)+61;
  49. buttonText[i][j]=Integer.toString(b);
  50. }
  51. }
  52.  
  53. }
  54.  
  55. JPanel buttons = new JPanel();
  56. buttons.setLayout(new GridLayout(5,5));
  57. JButton[][] button = new JButton [5][5];
  58. for(int i=0; i<5; i++){
  59. for(int j=0; j<5; j++){
  60. button[i][j] = new JButton(buttonText[i][j]);
  61. buttons.add(button[i][j]);
  62. }
  63. }
  64. JPanel actions1 = new JPanel();
  65. actions1.setLayout(new GridLayout(2,1));
  66. JButton[][] act = new JButton[2][1];
  67. for(int i=0; i<2; i++){
  68. for (int j=0; j<1; j++){
  69. act[i][j] = new JButton(actions[i][j]);
  70. buttons.add(button[i][j]);
  71. }
  72. }
  73. add(buttons, BorderLayout.NORTH);
  74.  
  75. add(buttons, BorderLayout.CENTER);
  76.  
  77. EventHandler eh = new EventHandler();
  78. //buttonText.addActionListener(eh);
  79. }
  80. public class EventHandler implements ActionListener{
  81. public void actionPerformed(ActionEvent e){
  82. if(e.getSource()== buttonText){
  83. }
  84. }
  85. }
  86.  
  87.  
  88. int count=-1;
  89. String [] numCalled = new String[200];//keeps track of numbers called
  90. //random number for new ball
  91. public void randNum(){
  92. Random r = new Random();
  93. int randvalue = r.nextInt(75)+1;
  94. count++;
  95. numCalled[count]= Integer.toString(randvalue);
  96.  
  97. }
  98.  
  99.  
  100.  
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement