| Author |
Help understanding why mouse event seems to be registering twice.
|
Felix Chien
Greenhorn
Joined: Sep 25, 2011
Posts: 4
|
|
I'm working on a applet that in part will update the user with the amount of times they have clicked and it seems that the variable I set 'count' is doing: count += 2; instead of what I put down as: count ++; I need help understanding why that is.
Any help is appreciated.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19214
|
|
Don't call init from your paint method. The paint method is called quite often, in some applets even multiple times per second. That means that you will do all that initialization each and every time. Instead, use the "regular" init method:
Note how I did move the changing of the color of page to the paint methods; that is the one thing from your old init method that you do want to occur during each paint.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Felix Chien
Greenhorn
Joined: Sep 25, 2011
Posts: 4
|
|
|
Ah, Thanks Rob! I was quite confused... That fix worked perfectly =D
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19214
|
|
|
You're welcome.
|
 |
 |
|
|
subject: Help understanding why mouse event seems to be registering twice.
|
|
|