title: While making a grid based prize founding game how do i conditionalize the actionPerformed?
body: <pre><code>import java.awt.*;
  import java.awt.event.*;
  import javax.swing.*;
  import java.util.HashMap;
  
  class ButtonGrid implements ActionListener {
      int numOfGuesses = 0;
  
      public static void main(String[] args) {
  
          Runnable r = new Runnable() {
  
              @Override
              public void run() {
                  JPanel gui = new JPanel(new BorderLayout(5, 5));
                  int prize = (int) (Math.random() * 25);
  
                  int sz = 5;
                  Container content = new JPanel(new GridLayout(sz, 0, 2, 2));
                  for (int f = 0; f &lt; sz * sz; f++) {
                      JButton button = new JButton(Integer.toString(f + 1));
  
                      content.add(button);
  
                  }
                  gui.add(content, BorderLayout.CENTER);
  
                  Container info = new JPanel(new FlowLayout(FlowLayout.CENTER, 50, 5));
                  info.add(new JLabel("Guess:"));
                  info.add(new JLabel(Integer.toString(numOfGuesses)));
                  gui.add(info, BorderLayout.PAGE_START);
  
                  gui.add(new JLabel("Label"), BorderLayout.LINE_END);
  
                  JOptionPane.showMessageDialog(null, gui);
              }
          };
          SwingUtilities.invokeLater(r);
      }
  
      @Override
      public void actionPerformed(ActionEvent event) {
          if(){
  
          }else{
              numOfGuesses++;
          }
      }
  }
  </code></pre>
  
  <p>Trying to make a find the prize type game on a 5x5 gird. On the top layer there will be a guess counter. How do i check if the prize integer is equal to the text the button holds and complete the if statement accordingly ?</p>