Results 1 to 4 of 4
Thread: Boolean issues
- 04-06-2010, 08:48 PM #1
Member
- Join Date
- Sep 2009
- Posts
- 21
- Rep Power
- 0
Boolean issues
Hey. In making a simple clicking applet, I've run into an odd problem.
Throughout explaining I'll be talking about one of the eight JButtons, as I really don't think it matters that I talk about all of them as they all have the same problem.
I declared a boolean, 'm1', which is set to true when check(), called by process(), generates a random number below a certain amount (specific for the level).
I got check(), icons() and actionPerformed(ActionEvent) to print m1. The result:
Java Code:Check: true Icons: true ActionEvent: false
Whenever the user clicks on the button, it goes false whether it's true or not. The methods are below.
process()
Java Code:public void process() { check(); repaint(); }
check()
Java Code:public void check() { int c1 = rN(tN);//rN(int) is the random number. if (c1 < hT) { if (m1) { m1 = false; } else { m1 = true; } } icons() }
icons()
Java Code:public void icons() { if (m1) { S1.setIcon(gI("GREEN"));//gI(String) collects an image from the sprites folder. } else { S1.setIcon(gI("RED")); } }
If you can and are willing to help, I'd like to know why it does that and how to stop it, or a way around it.
Thanks in advance. :)
- 04-06-2010, 10:20 PM #2
Member
- Join Date
- Sep 2009
- Posts
- 21
- Rep Power
- 0
What..? :l
-
Spammer blocked. Sorry for the inconvenience.
-
To the OP, you may want to create an SSCCE that demonstrates your problem as well as go into greater detail on what's going on. Please look at the third link in my signature below. Best of luck!
Similar Threads
-
Boolean methods
By sonny in forum New To JavaReplies: 7Last Post: 03-26-2010, 10:16 PM -
Boolean confusion
By KM88 in forum New To JavaReplies: 13Last Post: 11-02-2009, 12:44 PM -
Boolean method help
By syferite in forum New To JavaReplies: 6Last Post: 10-28-2009, 01:32 PM -
1 as an integer, not boolean
By McChill in forum New To JavaReplies: 1Last Post: 05-02-2009, 09:39 PM -
[SOLVED] if-else and boolean issues
By AngrYkIdzrUlE in forum New To JavaReplies: 21Last Post: 03-09-2009, 05:18 AM


LinkBack URL
About LinkBacks

Bookmarks