You are on page 1of 2

import javax.swing.*; import java.awt.

*; public class Trab5 extends JApplet implements Runnable { Thread t; boolean continua; int tam; public void init() { tam = 0; t = new Thread(this); } public void start() { continua = true; t.start(); } public void stop() { continua = false; } public void run() { while (continua) { try { Thread.sleep(33); repaint(); } catch (InterruptedException e) {} } } public void paint(Graphics g) { super.paint(g); g.fillOval(tam, 0, getSize().width - tam * 2, getSize().height g.setColor(Color.green); g.fillRect((int)(Math.random()*200), (int)(Math.random()*200), ndom()*100), (int)(Math.random()*200)); g.setColor(Color.red); g.fillRect((int)(Math.random()*200), (int)(Math.random()*200), ndom()*100), (int)(Math.random()*200)); g.setColor(Color.blue); g.fillRect((int)(Math.random()*200), (int)(Math.random()*200), ndom()*100), (int)(Math.random()*200)); g.setColor(Color.yellow); g.fillRect((int)(Math.random()*200), (int)(Math.random()*200), ndom()*100), (int)(Math.random()*200)); if ((tam-=1) < 0 || tam > getSize().width / 2) { tam = getSize().width / 2; } g.setColor(Color.red); g.drawString("Teste", tam, tam); } } class Main extends JFrame { Main() { Trab5 t = new Trab5(); t.init(); t.start();

- 1); (int)(Math.ra (int)(Math.ra (int)(Math.ra (int)(Math.ra

add(t); setSize(400, 400); setVisible(true); } public static void main(String s[]) { new Main(); } }

You might also like