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

    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.getContentPane().add(app.createComponents());
    f.setSize(550, 400);
    f.setVisible(true);

    //update function
    //re-display
    }

    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/" +
    "floorplan1.svg");
    panel.add(p);
    panel.add(svgCanvas);
    return panel;
    }



    }

  2. #2
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

    Default

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