Results 1 to 2 of 2
  1. #1
    dunff2k is offline Member
    Join Date
    Nov 2008
    Posts
    2
    Rep Power
    0

    Default Double Buffering

    Hey guys,

    I've seen all the chat on double buffering, yet having followed the guidelines my scribble application still flickers really badly. Here is the paint method:

    Java Code:
    @Override
    	public void paintControl(PaintEvent arg0) 
        {
    		
    		Image bufferImage = new Image(s.getDisplay(), s.getBounds());
    
            GC gcImage = new GC(bufferImage);
            
            // Draw the background
            gcImage.setBackground(arg0.gc.getBackground());
            gcImage.fillRectangle(bufferImage.getBounds());
    		
            // draw the stack of points I have been collecting from mouse events
    		for (int i =0;i<(l.size()-1);i++)
    		{
    			gcImage.drawLine(l.elementAt(i).x, l.elementAt(i).y,l.elementAt(i+1).x,l.elementAt(i+1).y);
    		}
    		
    		// draw the buffered image to the screen
    		arg0.gc.drawImage(bufferImage, 0, 0);
    		
    		// Clean up
            bufferImage.dispose();
    		
    	}

    Any ideas why?

  2. #2
    dunff2k is offline Member
    Join Date
    Nov 2008
    Posts
    2
    Rep Power
    0

    Default sorted

    Think I've sorted this, it seems the OS was redrawing the background when I was doing that too...so creating a shell with SWT.NO_BACKGROUND as a parameter in the constructor was the solution

Similar Threads

  1. [SOLVED] Double Buffering
    By Zosden in forum AWT / Swing
    Replies: 1
    Last Post: 07-24-2008, 03:28 AM
  2. Double Value problem
    By sakthivel123 in forum New To Java
    Replies: 2
    Last Post: 07-10-2008, 05:18 PM
  3. Replies: 0
    Last Post: 06-28-2008, 10:23 PM
  4. Double Buffering problem
    By aprenz in forum Java Applets
    Replies: 0
    Last Post: 05-28-2008, 05:26 AM
  5. Calculating sin of a double value
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-13-2008, 09:13 PM

Posting Permissions

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