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

2. import java.awt.* ; 

3. import java.applet.*; 

4.  

5. public class ButTA 

6.   extends Applet 

7.   implements ActionListener    

8.

9.   TextArea ta ;   

10.   Button butt ; 

11.   boolean firsttime = true

12.  

13.   public void actionPerformed ( ActionEvent ev )    

14.   { 

15.     if ( firsttime ) 

16.     { 

17.       ta.append ( "\nButton clicked" );    

18.       firsttime = false

19.     } 

20.     else 

21.       ta.append ( "\nAnd again .." ) ; 

22.  

23.   } 

24.  

25.   public ButTA () 

26.   { 

27.     butt = new Button ( "This is a button, obviously" ) ;  

28.     ta = new TextArea ( "This is a TextArea" , 6, 15 ) ;   

29.   } 

30.  

31.   public void init() 

32.   { 

33.     butt.addActionListener ( this ) ;    

34.     setBackground ( Color.pink ) ; 

35.  

36.     add ( butt ) ; 

37.     add ( ta ) ;     

38.     validate () ; 

39.   } 

40.

41. /* 

42. ====  conditional expression ========== 

43.   nr =   nr > 7  ?  1  :  nr   ; 

44. === nested ================ 

45. if ( firstcondition ) 

46.

47.    //... 

48.    if ( secondcondition ) 

49.    { 

50.      //... 

51.    } 

52.    else  // NOT secondcondition 

53.    { 

54.      //.... 

55.    } 

56.    //... 

57.

58. else  // NOT firstcondition 

59.

60.    //... 

61.

62.  

63. */