I decided to use double buffering to eliminate the flashing in my applet. But there is a problem. Instead of things moving slowly... everything is saved on to the screen and stays there. For example... the ball is suppose to move like any ball would... but instead it creates a line of balls that don't disappear. How can I fix this?
Swing doublebuffers by default. Have you considered it?
There is no emoticon for what I am feeling!
Martin vanPutten
Ranch Hand
Joined: Mar 26, 2006
Posts: 124
posted
0
I was just told how to double buffer... I don't know what swing double buffers are.
Jeff Albertson
Ranch Hand
Joined: Sep 16, 2005
Posts: 1780
posted
0
Originally posted by Martin vanPutten: I was just told how to double buffer... I don't know what swing double buffers are.
The sweet thing is that you don't have to know anything. It's part of the furniture. Just write the code that renders in a simple manner and if you are using Swing components, they will take care of the double buffering.
Originally posted by Martin vanPutten: I was just told how to double buffer... I don't know what swing double buffers are.
Where are you using double buffering?
This is an example of how you use it.
Notice that the only thing you have to do to implement double buffering with Applet is override update so it only call paint, and then in paint draw on the offscreen image. After the offscreen image is finished, then display it.
Martin vanPutten
Ranch Hand
Joined: Mar 26, 2006
Posts: 124
posted
0
The sweet thing is that you don't have to know anything. It's part of the furniture. Just write the code that renders in a simple manner and if you are using Swing components, they will take care of the double buffering.
I don't understand.
Martin vanPutten
Ranch Hand
Joined: Mar 26, 2006
Posts: 124
posted
0
The sweet thing is that you don't have to know anything. It's part of the furniture. Just write the code that renders in a simple manner and if you are using Swing components, they will take care of the double buffering.
I don't understand.
Jeff Albertson
Ranch Hand
Joined: Sep 16, 2005
Posts: 1780
posted
0
Do you know about Swing?
Martin vanPutten
Ranch Hand
Joined: Mar 26, 2006
Posts: 124
posted
0
no. i'm bad with knowing what exactly with what things do.
Martin vanPutten
Ranch Hand
Joined: Mar 26, 2006
Posts: 124
posted
0
Can somebody look through my code and point out the problem... then I could look at it... and try and figure it out?
Jeff Albertson
Ranch Hand
Joined: Sep 16, 2005
Posts: 1780
posted
0
I was asking if you knew Swing because most Java programmers who have the choice prefer Swing over the AWT. From your answer, although unclear, I assume you don't know Swing. Then I can't help you. I also avoid applets, but that's a story for another time...
Martin vanPutten
Ranch Hand
Joined: Mar 26, 2006
Posts: 124
posted
0
So is it possible to fix my problem with what I have now?
Jeff Albertson
Ranch Hand
Joined: Sep 16, 2005
Posts: 1780
posted
0
Originally posted by Martin vanPutten: So is it possible to fix my problem with what I have now?
Yes. Digest what Keith wrote. Again, it would be simpler if you knew Swing.