Double Buffer Java source code
#1

Code:
import java.awt.*;
import java.applet.*;
import java.awt.event.*;

/*
<applet code=DoubleBuffer width=300 height=300>
<param name="img" value="smile.jpg">
</applet>
*/

public class DoubleBuffer extends Applet
{
        int gap = 3;
        int mx,my;
        boolean flicker=true;
        Image buffer=null;
        int w,h;
        public void init()
        {
                Dimension d = getSize();
                w = d.width;
                h = d.height;
                buffer = createImage(w,h);
                addMouseMotionListener(new MouseMotionAdapter()
                {
                        public void mouseDragged(MouseEvent me)
                        {
                                mx = me.getX();
                                my = me.getY();
                                flicker = false;
                                repaint();
                        }
                        public void mouseMoved(MouseEvent me)
4                        {
                                mx = me.getX();
                                my = me.getY();
                                flicker = true;
                                repaint();
                        }
                });
        }
        public void paint(Graphics g)
        {
                Graphics screengc = null;
                if(!flicker)
                {
                        screengc = g;
                        g = buffer.getGraphics();
                }

                g.setColor(Color.blue);
                g.fillRect(0,0,w,h);

                g.setColor(Color.red);
                for(int i = 0;i<w;i+=gap)
                        g.drawLine(i,0,w-i,h);
                for(int i = 0;i<w;i+=gap)
                        g.drawLine(0,i,w,h-i);

                g.setColor(Color.black);
                g.drawString("Press mouse button to double buffer",10,h/2);

                g.setColor(Color.yellow);
                g.fillOval(mx-gap,my-gap,gap*2+1,gap*2+1);

                if(!flicker)
                        screengc.drawImage(buffer, 0 , 0,null);
                
        }
        public void update(Graphics g)
        {
                paint(g);
        }
}
Reply

Important Note..!

If you are not satisfied with above reply ,..Please

ASK HERE

So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page
Popular Searches: registration code for sims 2 double deluxe, double guard project source code, java double buffering example, double guard source code, source code for double guard, java double buffering source code, source code for double guard project,

[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Possibly Related Threads...
Thread Author Replies Views Last Post
  projects in core java project topics 6 16,127 16-01-2018, 11:15 AM
Last Post: dhanabhagya
  Steganography implemented in Java science projects buddy 14 12,170 24-05-2016, 10:15 AM
Last Post: dhanabhagya
  STUDENT INFORMATION SYSTEM IN JAVA project topics 14 10,606 19-08-2015, 11:28 PM
Last Post: Guest
  mini projects in java project topics 7 18,788 01-05-2015, 04:18 PM
Last Post: seminar report asees
  Visa Processing System full report and asp source code project topics 2 5,531 19-06-2014, 06:54 PM
Last Post: seminar report asees
  distributed cache updating for the dynamic source routing protocol project report tiger 4 3,000 05-03-2013, 02:22 PM
Last Post: Guest
  application projects in java and vb.net (titles and topics) project topics 1 5,497 28-11-2012, 01:11 PM
Last Post: seminar details
  Energy-Efficient Routing in Mobile Ad Hoc Networks: Mobility-Assisted Case (Java) project topics 1 1,755 12-11-2012, 12:42 PM
Last Post: seminar details
  Net Auction java based project report project topics 2 3,699 01-11-2012, 12:59 PM
Last Post: seminar details
  distributed applications using RMI-Java model. seminar class 1 1,475 31-05-2012, 12:29 AM
Last Post: Guest

Forum Jump: