I have an int variable that is set a certain value, when a JButton is clicked on the GUI the buttons visibility is set to false, and the counter variable should decrease by one. Once it hits 0 an if statement is executed. The problem is the counter variable keeps getting reset everytime I click a button. This is my code
public int someMethod(){
intVar= 3;
return intVar;
}
public void anotherMethod(){
intVar--;
}
public void actionPerformed(ActionEvent e) {
if (someCondition){
clickedButton.setVisible(false);
anotherMethod();
if (someMethod()==0){
//Do something
}