//this is a test import java.awt.*; import java.applet.Applet; import java.awt.event.*; import java.util.Random; public class Animated extends Applet implements Runnable{ myMouse m; Thread mythread=null; Image offscreenImg; Graphics offscreenG; int xpos=-100,ypos=60; public void init() { m = new myMouse(); addMouseMotionListener(m); offscreenImg = createImage(this.size().width,this.size().height); offscreenG = offscreenImg.getGraphics(); } public void start() { if (mythread == null) { mythread = new Thread(this); mythread.start(); } } public void stop() { if (mythread != null) { mythread.stop(); mythread = null; } } public void run() { while (true) { for (xpos=-110; xpos<=310; xpos+=4) { repaint(); try { Thread.sleep(100); } catch (InterruptedException e) { } } } } public void update(Graphics g) { g.setClip(null); g.clipRect(xpos-10,ypos+30,xpos/10+20,xpos/10+10); paint(g); g.setClip(null); g.clipRect(xpos-10, ypos-30, 160, 40); paint(g); } public void paint (Graphics g) { offscreenG.setColor(Color.cyan); offscreenG.fillRect(0,0,100,150); offscreenG.setColor(Color.white); offscreenG.fillRect(100,0,200,150); Color myRandom = new Color(0,m.mouseX,0); offscreenG.setColor(myRandom.brighter()); Font myFont = new Font("Helvetica",Font.BOLD,32); offscreenG.setFont(myFont); offscreenG.drawString("Catch Me",xpos,ypos); offscreenG.setColor(Color.yellow); Font myFont1 = new Font("Helvetica",Font.PLAIN,32); offscreenG.setFont(myFont); offscreenG.drawString("Catch Me",xpos-5,ypos); Color myRandom1 = new Color(m.mouseY,m.mouseX,0); offscreenG.setColor(myRandom1.brighter()); offscreenG.fillOval(xpos,ypos+30,xpos/10+10,xpos/10+10); g.drawImage(offscreenImg,0,0,this); } }