-
November 23rd, 2003, 11:16 AM
#1
Repaint - flickerings
Hi,
I'm having a little problem with a Java applet .. no idea if it's solvable or if this is just the way Java applets look like. Me new to JAVA .. so me no experience to rely on
Anyways ..
This is the applet in question. Forget the content of the fields - the pictures and the text are just placeholding bogus for now. The fields should change their color when the mouse moves over them. I do that by constantly monitoring the mouse coordinates .. and saving them. Next time the coordinates are captured, I compare them with the last ones .. if the old ones are outside the box and the new ones are inside, the color with which I drew the ractangle is changed .. and I use the command "repaint()"
The problem .. it flickers. Too much. Is there a different way with which I can draw graphics outside of the paint method that doesn't cause this kind of flickering? Or is there a way to repaint only a limited part of the screen? Or any other way in which I could improve this?
Thanks,
Jeremy
-
November 23rd, 2003, 04:13 PM
#2
Try Double buffering. The idea is to paint on a rendered image, then paint the image.
http://www.javaworld.com/javaworld/j...l#doubleBuffer
Last edited by Goodz13; November 23rd, 2003 at 04:16 PM.
-
November 26th, 2003, 04:10 AM
#3
Got it to work .. thanks a lot
One tiny problem I had with this was that it would not paint the first frame until I click my mouse for the first time .. I solved this problem by defining a int that I set 0 .. and in my
public void mouseEntered( MouseEvent e )
tell the computer to repaint if that variable is 0 and to then set the variable to 1 again. Which means .. I get a picture as soon as the mouse is over the applet space. Since the applet space is the whole screen .. this is okay. I was just wondering though .. if there is a more efficent/orthodox/common way to make sure that the first frame is drawn. No catastrophy if there isn't, it's fine as it is
-
November 26th, 2003, 06:34 AM
#4
why not just tell it to repaint whenh youre done pre-processing
-
November 26th, 2003, 09:14 AM
#5
the void paint(Graphics g) is called right after the applet is inited.
post your first picture code there.
Vision.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|