Results 1 to 2 of 2
  1. #1
    rukawa527 is offline Member
    Join Date
    Feb 2009
    Rep Power

    Default Need Help: Double Buffer

    I'm using java program to display up a svg file. I would like to include double buffer method since the file will be periodically updated and re-displayed. Can anyone show me hw i suppose to add in the coding of double buffer?

    Here's my code:
    __________________________________________________ ___________
    import java.awt.*;
    import javax.swing.*;
    import org.apache.batik.swing.JSVGCanvas;

    public class displaySVG extends JFrame {

    Thread thrd;
    protected JFrame f; //The frame.
    protected JSVGCanvas svgCanvas = new JSVGCanvas();

    public displaySVG(JFrame f) {
    this.f = f;

    public void displaySVG(){
    // Create a new JFrame.
    displaySVG app = new displaySVG(f);

    // Add components to the frame.
    f.setSize(550, 400);

    //update function

    public JComponent createComponents() {

    // Create a panel and add the button, status label and the SVG canvas.
    final JPanel panel = new JPanel(new BorderLayout());
    JPanel p = new JPanel();
    svgCanvas.setURI("file:/C:/Documents and Settings/Ricky" +
    "/My Documents/NetBeansProjects/Project_test1/" +
    return panel;


  2. #2
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Rep Power


    For many JComponents, isDoubleBuffered is a property of the component, and the component handles the buffering.

    In the case of JSVGCanvas (actually, an Apache Batik class), it uses isDoubleBufferedRendering and setDoubleBufferedRendering. Just setDoubleBufferedRendering(true) before you display it.

    Double buffering means that the component maintains two buffers, one with the currently displayed information, and a second in which new information can be built without interfering with the display. Each time the component is rendered, the buffers swap roles.

    This is only useful if generating the information for the component takes a long time, from the human eye's perspective, and it doubles the memory required to hold the data.

Similar Threads

  1. Buffer
    By QPRocky in forum Networking
    Replies: 2
    Last Post: 02-02-2009, 04:54 PM
  2. Double.valueOf() vs Double.parseDouble()
    By greenbean in forum New To Java
    Replies: 10
    Last Post: 01-12-2009, 09:39 AM
  3. Can't DOUBLE BUFFER images
    By hunterbdb in forum Java 2D
    Replies: 7
    Last Post: 11-14-2008, 09:53 PM
  4. Help with String Buffer
    By mathias in forum AWT / Swing
    Replies: 1
    Last Post: 08-07-2007, 07:52 AM
  5. how to set the value of BUFFER SIZE
    By oregon in forum Advanced Java
    Replies: 1
    Last Post: 08-06-2007, 04:16 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