import java.awt.*; public class example3 extends BufferedApplet { int w = 0, h = 0; Font font = new Font("Helvetica", Font.BOLD, 48); double time0; int mx = 0, my = 0; public void render(Graphics g) { if (w == 0) { w = bounds().width; h = bounds().height; mx = w/2; my = h/2; time0 = System.currentTimeMillis() / 1000.0; } double time = System.currentTimeMillis() / 1000.0; double elapsed = time - time0; g.setColor(Color.white); g.fillRect(0, 0, w, h); g.setColor(Color.red); g.fillRect(mx - w/6, my - h/6, w/3, h/3); int j = (int)(100 * Math.sin(elapsed * (2 * Math.PI))); int k = (int)( 20 * Math.cos(elapsed * (2 * Math.PI))); g.setColor(Color.black); g.fillOval(mx - w/6, my - h/6 + j, w/3, w/3 - k); animating = true; } public boolean mouseMove(Event e, int x, int y) { mx = x; my = y; damage = true; return true; } }