/* 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. public class AbTrek 

2.   extends Applet implements ActionListener 

3.

4.   Incomplete  icone, ictwo ; 

5.   Button bt = new Button( "....Doowit....." ); 

6.   int clcount = 0

7.  

8.   public AbTrek () 

9.   { 

10.      icone = new DoItMyWay() ; 

11.      ictwo = new AnotherWay() ; 

12.     add ( icone ) ; 

13.     add ( ictwo ) ; 

14.     icone.setBackground( Color.yellow ); 

15.     ictwo.setBackground( Color.cyan ); 

16.     bt.addActionListener(this); 

17.     add( bt ); 

18.   } 

19.  

20.   public void actionPerformed( ActionEvent e ) 

21.   { 

22.     icone.doowit(); 

23.     ictwo.doowit(); 

24.     clcount++ ; 

25.     bt.setLabel( "Clicked : " + clcount ); 

26.   } 

27.

28. ======= Incomplete.java =========== 

29.  

30. abstract class Incomplete 

31.   extends java.awt.Panel 

32.

33.   abstract void doTheRightThing () ; 

34.  

35.   void doowit() 

36.   { 

37.       doTheRightThing() ; 

38.   } 

39.

40. ======= DoItMyWay.java =========== 

41. import java.awt.* ; 

42.  

43. class DoItMyWay 

44.   extends Incomplete 

45.

46.   int count = 0

47.  

48.   void doTheRightThing() 

49.   { 

50.     if ( count > 2 ) remove( 0 ); 

51.     add ( new Button ( "Nr." + count ) ); 

52.     count++ ; 

53.     validate(); 

54.   } 

55.  

56.   public Dimension 

57.   getPreferredSize() 

58.   { 

59.    return new Dimension( 200,100 ) ; 

60.   } 

61.

62. ======= AnotherWay.java =========== 

63. import java.awt.* ; 

64.  

65. class AnotherWay 

66.   extends Incomplete 

67.

68.   int count = 0

69.  

70.   void doTheRightThing() 

71.   { 

72.     if ( count > 3

73.     { 

74.       removeAll() ; 

75.       count = 0

76.       return

77.     } 

78.     add ( new Button ( "# "  + count )  ) ; 

79.     count++ ; 

80.     validate(); 

81.   } 

82.  

83.   public Dimension 

84.   getPreferredSize() 

85.   { 

86.    return new Dimension( 100,150 ) ; 

87.   } 

88.

89. ========== java/io/OutputStream.java ========= 

90.  

91. public abstract class OutputStream 

92.

93. ..(simplified).. 

94.  

95. public abstract void write( byte b ) ; 

96.  

97. public void 

98. write( byte b[], int off, int len ) 

99.

100. ... 

101.   for (int i = 0 ; i < len ; i++ ) 

102.   { 

103.       write( b[off + i] ) ; 

104.   } 

105.

106. .... 

107.

108.