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.
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.
Can you help me make this counter work properly? I also used printline but that gave some errors too.
My code for the counter is this:
button1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
label1.setVisible(true);
int counter = 1;
while(counter < 5 )
{
label1.setText("counter is " + counter);
counter = counter + 1 ;
}
counter = 1;
tk.beep();
}
});