Explanation:
I have a JTextField
component that would be a countdown timer, but when I use ActionListener
this way:
public static ActionListener alredBGolem = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
redBGolem.setText(String.valueOf(tempoRedBGolem));
tempoRedBGolem--;
}
};
It works correctly, but when calling a function:
public static JTextField redBGolem = new JTextField();
private static int tempoRedBGolem = 300;
private static Timer timerRedBGolem = new Timer(1000, alredBGolem);
public static ActionListener alredBGolem = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
count(redBGolem,timerRedBGolem,tempoRedBGolem,1);
}
};
public static void count(JTextField Field, Timer cTimer, int Tempo, int Type){
Field.setText(String.valueOf(Tempo));
Tempo--;
System.out.println(Tempo);
}
It only prints 299
repeatedly and JTextField
does not exit 300
.
How do I solve this problem?