import java.awt.*;

public class CopyCanvas extends Canvas {
    public CopyCanvas(){
        setBackground(Color.white);
    }

        // Draw a rectangle and then move a quadrant west.
    public void paint(Graphics g){
        Dimension size = getSize();
        // The dimensions of the main rectangle.
        final int width = size.width/3, height = size.height/3;
        // Where to place the main rectangle.
        final int x = size.width/3, y = size.height/3;

        g.fillRect(x,y,width,height);
        // Copy a chunk.
        final int chunkWidth = width/2, chunkHeight = height/2;
        // Where from.
        final int chunkX = x+width/4, chunkY = y+height/4;
        // Copy it to just inside the left edge of the canvas.
        final int xoffset = -(chunkX-5), yoffset = 0;
        g.copyArea(chunkX,chunkY,chunkWidth,chunkHeight,xoffset,yoffset);
        // Clear the removed area.
        g.clearRect(chunkX,chunkY,chunkWidth,chunkHeight);
    }
}
