Results 1 to 7 of 7
  1. #1
    Atriamax is offline Member
    Join Date
    Sep 2009
    Posts
    41
    Rep Power
    0

    Default Double Buffering Graphics in a Frame

    I have a program that creates great images using mathematical algorithms. I have it so it can animate the image, but right now, it looks ugly because theres so much flickering and it jumps, and its just looks bad. I know what i have to do to, double buffer, but I can only find out how to do that on an applet. It seems on a frame (or panel) it doesnt work right. Can anyone tell me how i could double buffer my graphics on a panel or frame?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  3. #3
    Atriamax is offline Member
    Join Date
    Sep 2009
    Posts
    41
    Rep Power
    0

    Default

    I am, i have double buffering enabled, but i know what i need to do. I want to render the frames before displaying them, then just display the 50 frames in sequence (looped). I was going to program it to double buffer the whole thing, then just flip through them. What Im doing requires thousands of calculations, so this is how i must do it.

  4. #4
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,234
    Rep Power
    7

    Default

    Do your rendering up front to a BufferedImage. Then each time you animate the panel you simply draw a different image.

  5. #5
    Atriamax is offline Member
    Join Date
    Sep 2009
    Posts
    41
    Rep Power
    0

    Default

    Thats what i am trying to figure out how to do camickr!
    How do i draw to a bufferedimage?
    I tried it using createImage(w,h) and IMAGE.getGraphics()
    but it kept giving me null pointer errors on the graphics

  6. #6
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,234
    Rep Power
    7

    Default

    Thats what i am trying to figure out how to do camickr!
    No, your question was about "double buffering". You where told that double buffering is done by default so you don't worry about it.

    It was then suggested that you might be able to use a BufferedImage to render your images in advance so you don't have to rerender them each time you want to change images.

    So now you have a NEW question about using BufferedImages? Did you search the forum for examples that use BufferedImages?

    I'm partial to my Custom Painting Approaches example which should get you started. Of course your code will be different because the example dynamically adds to a single BufferedImage, whereas you will have 50 different BufferedImages that a animated sequentially.

    If you need more help post your SSCCE showing the problem.

  7. #7
    Atriamax is offline Member
    Join Date
    Sep 2009
    Posts
    41
    Rep Power
    0

    Default

    I asked about double buffering because i was going to use the same strategy you use to manually double buffer something to render my images. And I was further trying to find that out by asking how to draw to a buffered image. I looked at code on double buffering an applet and used the same methods on my program, but it didnt work. So I was trying to find out how one would do it in a panel or frame and try that.
    does that clear things up?
    Ill try looking at your example and using what you use in that.
    Last edited by Atriamax; 11-02-2009 at 02:39 AM.

Similar Threads

  1. Double Buffering an Application?
    By Moncleared in forum New To Java
    Replies: 8
    Last Post: 09-14-2009, 04:45 AM
  2. Double Buffering
    By dunff2k in forum SWT / JFace
    Replies: 1
    Last Post: 11-14-2008, 03:26 PM
  3. [SOLVED] Double Buffering
    By Zosden in forum AWT / Swing
    Replies: 1
    Last Post: 07-24-2008, 02:28 AM
  4. Replies: 0
    Last Post: 06-28-2008, 09:23 PM
  5. Double Buffering problem
    By aprenz in forum Java Applets
    Replies: 0
    Last Post: 05-28-2008, 04:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •