import java.awt.*; public class example2 extends BufferedApplet { int x = 0, y = 0; int w = 0, h = 0; Color drawingColor = Color.black; int counter = 0; double weight = 0; public void render(Graphics g) { if (w == 0) { w = bounds().width; h = bounds().height; x = w / 2; y = h / 2; } g.setColor(Color.white); g.fillRect(0, 0, w, h); int isin = (int)(100 * Math.sin(0.1 * counter)); int icos = (int)(100 * Math.cos(0.1 * counter)); int jsin = (int)(weight * 20 * Math.sin(0.6 * counter)); int jcos = (int)(weight * 20 * Math.cos(0.6 * counter)); g.setColor(drawingColor); g.fillOval(x - 35 + isin - jsin/2, y - 25 + icos - jcos/2, 70 + jsin, 50 + jcos); weight *= 0.95; counter++; animating = true; } public boolean mouseMove(Event e, int x, int y) { return false; } public boolean mouseDown(Event e, int x, int y) { return false; } public boolean mouseDrag(Event e, int x, int y) { this.x = x; this.y = y; damage = true; return true; } public boolean mouseUp(Event e, int x, int y) { weight = 1.0; return false; } public boolean keyDown(Event e, int key) { return false; } public boolean keyUp(Event e, int key) { switch (key) { case 'r': drawingColor = Color.red; break; case 'g': drawingColor = Color.green; break; case 'b': drawingColor = Color.blue; break; case ' ': drawingColor = Color.black; break; } damage = true; return true; } }