title: I want to add a counter into my game where it prints into the console.
body: <p>So my code starts off this way in the Start Button Handler for my game.  The goal is to have random buttons to select and then click those random buttons and print out the number of times you clicked the button into the console.  But I have no idea how to do so.  Here is my code so far :</p>
  
  <p>My Start button class :</p>
  
  <pre><code>package code;
  
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.util.Random;
  
  import javax.swing.JButton;
  import javax.swing.JComponent;
  import javax.swing.JFrame;
  import javax.swing.JLabel;
  import javax.swing.JPanel;
  import javax.swing.Timer;
  
  
  
  public class StartButton implements ActionListener{ 
  
      int clickCounter;
      private JFrame _j;
      public StartButton(JFrame frame){
          _j = frame;
      }
      public void actionPerformed (ActionEvent e) {     
  
          JFrame frame2 = new JFrame("ABC");
  
  
          frame2.setVisible(true);
          frame2.setSize(200,200);
          frame2.setLocationRelativeTo(null);
          JLabel label = new JLabel("Game");
          JPanel panel = new JPanel();
          frame2.add(panel);
          panel.add(label);       
          _j.setVisible(false); //This creates a new game frame
  
  
  
  
  
  
          JButton button = new JButton("A");
          panel.add(button);
  
  
  
          JButton button1 = new JButton("B");
          panel.add(button1);
  
          JButton button2 = new JButton("C");
          panel.add(button2);
  
          ButtonHandler b;
          b = new ButtonHandler (button, button1, button2);
          button.addActionListener(b);
          button1.addActionListener(b);
          button2.addActionListener(b);
  
          Random r = new Random();
          int x = r.nextInt(3);
  
  
  
          if (x==0) {button.setEnabled(true); button1.setEnabled(false); button2.setEnabled(false);}
          if (x==1) {button1.setEnabled(true); button.setEnabled(false); button2.setEnabled(false);}
          if (x==2) {button2.setEnabled(true); button.setEnabled(false); button1.setEnabled(false);}
  
          Timer t = new Timer (10000, null);
          t.addActionListener(new GameCloser());
          t.start();
  
  
  
      }
  
  
  
  
  
  }
  
  My ButtonHandler Class :
  
      package code;
  
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;
      import java.util.Random;
  
      import javax.swing.JButton;
  
      public class ButtonHandler implements ActionListener {
      private JButton _b1;
      private JButton _b2;
      private JButton _b3;
  
      public ButtonHandler(JButton button, JButton button1, JButton button2){
      _b1 = button;
      _b2=button1;
      _b3=button2;
  }
  
      @Override
      public void actionPerformed(ActionEvent arg0) {
           Random r = new Random();
           int x = r.nextInt(3);
  
  
  
           if (x==0) {_b1.setEnabled(true); _b2.setEnabled(false); _b3.setEnabled(false);}
           if (x==1) {_b2.setEnabled(true); _b1.setEnabled(false); _b3.setEnabled(false);}
           if (x==2) {_b3.setEnabled(true); _b1.setEnabled(false); _b2.setEnabled(false);}
               }
  
      }   
  
  
  ANd here is my my class for closing the game:
  
      package code;
  
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;
  
      public class GameCloser implements ActionListener {
  
      @Override
      public void actionPerformed(ActionEvent e) {
  
          System.out.println("Congrats, you clicked it "+" times");
          System.exit(0);
  </code></pre>
  
  <p>HOW DO I FIT A COUNTER :( ??</p>