title: Java Swing how can I make this counter work?
body: <p>Everytime my counter reaches 4 I want it to play a beep sound and go back to '1' and again count up to 4 play the beep sound and so on.</p>
  
  <p>I probably shouldn't place this in a label, because the counter doesnt run at all! 
  I don't get any errors but the label says; counter is 4 and doesnt count or anything.</p>
  
  <p>Can you help me make this counter work properly? I also used printline but that
  gave some errors too. </p>
  
  <p>My code for the counter is this:</p>
  
  <pre><code>button1.addActionListener(new ActionListener() {
  
    public void actionPerformed(ActionEvent arg0) {
  
      label1.setVisible(true);
      int counter = 1;
  
      while(counter &lt; 5 )
      {
        label1.setText("counter  is " + counter);
        counter = counter + 1 ;
      }
  
      counter = 1;
      tk.beep();
    }
  });
  </code></pre>