Two Laptop Bag*
The moose likes Beginning Java and the fly likes jbutton problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "jbutton problem" Watch "jbutton problem" New topic
Author

jbutton problem

James Smith
Greenhorn

Joined: Dec 19, 2002
Posts: 12
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?
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
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
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
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.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Robbie shi
Greenhorn

Joined: Jan 05, 2003
Posts: 28
can you show your code
?
i want to check it
--
Robbies
-----------------------------
1.java IDE tool : JawaBeginer
2.Java Jar tool : JavaJar
http://www.pivotonic.com
-----------------------------
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jbutton problem
 
Similar Threads
Having trouble getting to while loop
Annoying Error
Null Pointer Exception
Help with this code
Jbutton