/* Copyright (c) SEMM NL All rights reserved.
Author : Paul Hamaker. Part of JavaLessons.com
This code is for educational purposes only. Use at own risk.*/

1. import java.awt.* ; 

2. import java.applet.* ; 

3.  

4. public class ArrayPaint 

5.   extends Applet 

6. {   

7.   int [ ] ar1 ; 

8.   int [ ] ar2 ; 

9.  

10.   public void init() 

11.   { 

12.     setBackground ( Color.blue ) ; 

13.  

14.     ar1 = new int [ 500 ] ; 

15.     ar2 = new int [ 500 ] ; 

16.  

17.     int x ; 

18.     for

19.       x = 0

20.       x <= 499

21.       x++ 

22.       ) 

23.     { 

24.       double r1 ; 

25.  

26.       r1 = Math.random() ; 

27.       r1 = r1 * 350

28.       ar1 [ x ] = (int) r1 ; 

29.  

30.       ar2 [ x ] = (int)( Math.random() * 200 ) ;  

31.     } 

32.   } 

33.  

34.   public void paint( Graphics gr ) 

35.   { 

36.     gr.setColor ( Color.white ) ; 

37.  

38.     for (  int count = 0

39.         count <= 400

40.         count ++  ) 

41.     { 

42.       gr.fillOval (  ar1 [ count ], 

43.                 ar2 [ count ],    

44.                 2, 2 ) ; 

45.     } 

46.  

47.     gr.setColor ( Color.yellow ) ; 

48.  

49.     for (  int count = 401

50.         count < ar1.length ; 

51.         count ++  ) 

52.     { 

53.       gr.fillOval (  ar1 [ count ], 

54.                 ar2 [ count ], 

55.                 4, 2 ) ; 

56.     } 

57.   } 

58.  

59.