mardi 23 décembre 2014

Action Listener If Statements With Counter Breaking

I am creating a randomizer program for a small game and I am having an issue with the transitions. When you click Next to figure out who you are in the game, it will bring you to a blank page, waiting for the next person to click Next to figure out their position in the game. After Clicking the button once, the code breaks, no warnings, no errors, not any issues seem to be found.



next.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
if(countertwo == 0){
job1.setVisible(true);
counter++;
}
if(countertwo == 1){
job1.setText("Ready");
}
if(countertwo == 2){
job2.setVisible(true);
job1.setVisible(false);
}
}
});


So the first time you click on the button it sets the visibility for the First spot in the randomized/re-arranged list to be visible. Then after clicking it again, it hides your position and makes it say, "Ready", or "Click for your position" so when you click it again, it makes the next person's position visible", and repeats until all positions are handed out. FYI: there are 4 positions, by default all jobs'(job1, job2, etc) are hidden. Countertwo equals 0 by default.


Thank you, Coler234


Aucun commentaire:

Enregistrer un commentaire