home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Font;
- import java.awt.Graphics;
-
- public class ThreadApplet6 extends Applet {
- ColorThread2 thread1;
- ColorThread3 thread2;
- Color color1;
- Color color2;
- Color color3;
- Font font;
-
- public void start() {
- this.color1 = Color.red;
- this.color2 = Color.green;
- this.color3 = Color.blue;
- this.thread1 = new ColorThread2(this);
- this.thread1.start();
- this.thread2 = new ColorThread3(this);
- this.thread2.start();
- }
-
- public void stop() {
- this.thread1.stop();
- this.thread2.stop();
- }
-
- public void paint(Graphics var1) {
- var1.setColor(this.color1);
- var1.fillRect(30, 50, 50, 100);
- var1.setColor(this.color2);
- var1.fillRect(100, 50, 50, 100);
- var1.setColor(this.color3);
- var1.fillRect(170, 50, 50, 100);
- }
-
- public synchronized void SetColors(Color var1, Color var2, Color var3) {
- this.color1 = var1;
- this.color2 = var2;
- this.color3 = var3;
- ((Component)this).repaint();
- }
- }
-