/* 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.lang.* ; 

2. import java.awt.event.* ; 

3. import java.awt.* ; 

4. import java.applet.*; 

5.  

6. public class Str 

7.   extends Applet 

8.   implements ActionListener 

9.

10.   String struno = "String along" ;      

11.   String strdue = "We perceive time" ;    

12.  

13.   TextArea ta ; 

14.   Button bt ; 

15.  

16.   int cnt = 0

17.  

18.   public void actionPerformed ( ActionEvent ev ) 

19.   { 

20.     cnt++; 

21.  

22.     if ( cnt == 1

23.     { 

24.       struno.toUpperCase(); 

25.  

26.       ta.append ( "...First click, no change\n\n" ); 

27.       showum(); 

28.       return

29.     } 

30.     if ( cnt == 2

31.     { 

32.       strdue = struno.toUpperCase();   

33.  

34.       ta.append ( "...Second click, a new String\n\n" ); 

35.       showum(); 

36.       return

37.     } 

38.     if ( cnt == 3

39.     { 

40.       struno = struno.toUpperCase();   

41.  

42.       ta.append ( "...Third click, one String left\n\n" ); 

43.       showum(); 

44.       bt.setEnabled (false) ; 

45.       return

46.     } 

47.   } 

48.   void  showum () 

49.   { 

50.     ta.append ( "struno  refers to : " + struno + "\n" ); 

51.     ta.append ( "strdue  refers to : " + strdue + "\n" ); 

52.     ta.append ( "===============================\n" ); 

53.   } 

54.   public Str () 

55.   { 

56.     bt = new Button ( "Make it so !" ) ; 

57.     ta = new TextArea (  20, 50 ) ; 

58.   } 

59.  

60.   public void init () 

61.   { 

62.     bt.addActionListener ( this ) ; 

63.     setBackground ( Color.lightGray ) ; 

64.  

65.     add ( ta ) ; 

66.     add ( bt ) ; 

67.     validate () ; 

68.  

69.     showum(); 

70.   } 

71.

72. /*================ 

73.   someref = null

74.   somearray = null

75.   System.gc(); 

76. */