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

4.  

5. public class Break 

6.     extends Applet 

7.     implements ActionListener 

8.

9.   Button  btnpartall, btnfill ; 

10.   boolean entir = true

11.   TextArea ta ; 

12.   Label lbl ; 

13.  

14.   public 

15.   Break ( ) 

16.   { 

17.     btnpartall = new Button ( "Entirely or a small part" ) ; 

18.     btnfill = new Button ( "Fill 'r up" ) ; 

19.     ta = new TextArea ( 10, 20 ); 

20.     lbl = new Label ( "In its entirety" ) ; 

21.   } 

22.  

23.   public void 

24.   init() 

25.   { 

26.     setBackground ( Color.pink ) ; 

27.     btnpartall.addActionListener ( this ) ; 

28.     btnfill.addActionListener ( this ) ; 

29.  

30.     add ( btnpartall ) ; 

31.     lbl.setBackground ( Color.cyan ) ; 

32.     add ( lbl ) ; 

33.     add ( btnfill ) ; 

34.     add ( ta ); 

35.  

36.     validate() ; 

37.   } 

38.  

39.   void 

40.   fillTheArea () 

41.   { 

42.     ta.setText ( "" ) ; 

43.  

44.     for ( int i=0 ; i < 200 ; i++ ) 

45.     { 

46.       ta.append ( i + " \n" ); 

47.  

48.       if ( ! entir  &&  i > 6

49.         break

50.     } /// end for     

51.  

52.     ta.append ( "Left the loop" ); 

53.   } 

54.  

55.   public void 

56.   actionPerformed( ActionEvent ev ) 

57.   { 

58.     Object src = ev.getSource (); 

59.  

60.     if ( src == btnfill ) 

61.     { 

62.       fillTheArea () ; 

63.       return

64.     } 

65.  

66.     entir = !entir ; 

67.     if ( entir ) 

68.       lbl.setText ( "Entirely" ); 

69.     else 

70.       lbl.setText ( "Part of it" ); 

71.   } 

72.

73. ====== other source : =========== 

74. void someMeth() { 

75.   int  rating = 2

76.   String rats = ""

77.   switch ( rating ) 

78.   { 

79.    case 0 : rats = "disappointing" ; break

80.    case 1 : rats = "adequate" ; break

81.    case 2

82.    case 3 : rats = "cool" ; break

83.    default : rats = "unknown"

84.   } 

85.   System.out.println ( "Result is " + rats ) ; 

86.

87. =============== 

88. ||  OR 

89. &&  AND 

90. !  NOT 

91.  

92.