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