Im reading the dietel java book right now. On chapter 6 theres an example using a jbutton in a game of craps. The action listener is applied to the jbutton. My problem is this: in the actionlistener method, the first line is if (firstroll) call rolldice(); firstroll was initialized in the class as a boolean set = true the book explains it as true means its the start of a new game, and false means continue the game. is this the regular technique of utilizing jbuttons? with a booleans true/false way of doing things?
Well, no. I have NEVER used a boolean check in the action of a button. However, I have never had a GUI that had to know if this was the FIRST time the button was pushed or not. My buttons have all done the same thing no matter how many times that you pushed them. That is just a bit of logic that was used because of the scenario.
"JavaRanch, where the deer and the Certified play" - David O'Meara
is this the regular technique of utilizing jbuttons? with a booleans true/false way of doing things? I have seen many new programmers control the flow of a program using such a technique. I'm sure I did so when I wrote my first few game Applets. As I read more and wrote more programs and asked and answered more questions here at JavaRanch, I learned better/different ways to control the flow of a program.