All pastes #952780 Raw Edit

Anonymous

public text v1 · immutable
#952780 ·published 2008-03-22 15:02 UTC
rendered paste body
import java.applet.*;
import java.awt.event.*;
import java.awt.*;

public class Main extends Applet implements MouseMotionListener
{
     Graphics bufferGraphics;
     Image offscreen;
     Dimension dim;
     int curX, curY;
     Image back;

     public void init() 
     {
          dim = getSize();
          addMouseMotionListener(this);
          back = getImage(getDocumentBase(),"bg.jpg");
          //setBackground(Color.black);
          
          offscreen = createImage(dim.width,dim.height);
          bufferGraphics = offscreen.getGraphics();
     }

      public void paint(Graphics g) 
     {
    	  g.drawImage(back,0,0,this); 
    	  
          bufferGraphics.clearRect(0,0,dim.width,dim.width);
          bufferGraphics.setColor(Color.red);
          bufferGraphics.drawString("Double-buffered",10,10);

          bufferGraphics.fillRect(curX,curY,20,20);
          g.drawImage(offscreen,0,0,this);
     }


     public void update(Graphics g)
     {
          paint(g);
     }
 

     public void mouseMoved(MouseEvent evt) 
     {
          curX = evt.getX();
          curY = evt.getY();
          repaint();
     }
 

     public void mouseDragged(MouseEvent evt) 
     {
     }

 }