I want to show the user their clicks per seconds (CPS), therefore I want to set the Label, which displays the clicks, every second to 0. The problem is that I need to set the Label to static, and this is not working. Here is my code:
public class Controller{
public Button clickButton;
public Label cpsLabel;
public Label highscoreLabel;
static int count = 0;
// static int highscoreInt = 0;
public void handleButtonClick() {
count++;
cpsLabel.setText("CPS: " + count);
}
public static void Timer() {
ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor();
exec.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
Controller.count = 0;
cpsLabel.setText("CPS: " + count);
}
}, 0, 1, TimeUnit.SECONDS);
}
}