CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2003
    Location
    American living in Vienna, Austria
    Posts
    19

    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

  2. #2
    Join Date
    Jan 2002
    Location
    Halifax, NS, Canada
    Posts
    985
    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.

  3. #3
    Join Date
    Nov 2003
    Location
    American living in Vienna, Austria
    Posts
    19
    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

  4. #4
    Join Date
    Oct 2003
    Location
    .NET2.0 / VS2005 Developer
    Posts
    7,104
    why not just tell it to repaint whenh youre done pre-processing
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

  5. #5
    Join Date
    Apr 2003
    Location
    Israel
    Posts
    398
    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
  •  





Click Here to Expand Forum to Full Width

Featured