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

2.  

3. import java.awt.*; 

4. import java.awt.event.*; 

5. import java.util.*; 

6.  

7. public class OurBean 

8.   extends Canvas 

9.   implements java.io.Serializable 

10.

11.   private transient Vector als; 

12.  

13.   public synchronized void addActionListener( ActionListener lis ) 

14.   { 

15.     als.addElement( lis ); 

16.   } 

17.   public synchronized void removeActionListener( ActionListener lis ) 

18.   { 

19.     als.removeElement( lis ); 

20.   } 

21.  

22.  

23.   public class MA extends MouseAdapter 

24.   { 

25.     public void mouseClicked ( MouseEvent ev ) 

26.     { 

27.       ActionEvent ae = 

28.         new ActionEvent ( OurBean.this, ActionEvent.ACTION_PERFORMED, "DoeWat" ); 

29.  

30.       synchronized ( als ) 

31.       { 

32.         Enumeration en = als.elements(); 

33.         ActionListener al ; 

34.  

35.         while ( en.hasMoreElements() ) 

36.         { 

37.           al = (ActionListener) en.nextElement() ; 

38.           if ( al != null

39.             al.actionPerformed( ae ); 

40.         } 

41.       } ///end synchronized ( als ) 

42.     } 

43.   } 

44.   public OurBean () 

45.   { 

46.     addMouseListener ( new MA() ); 

47.     als = new Vector ( 5, 2 ) ; 

48.     setBackground ( Color.pink ) ; 

49.   } 

50.   public void paint ( Graphics g ) 

51.   { 

52.     g.drawString ( "Chili sin carne", 50, 40 ); 

53.   } 

54.   public Dimension getPreferredSize() 

55.   { 

56.     return new Dimension( 200, 100 ); 

57.   } 

58.   public Dimension getMinimumSize() 

59.   { 

60.     return new Dimension( 200, 100 ); 

61.   } 

62.

63. ===== META-INF/MANIFEST.MF  in some.jar ======= 

64.  Manifest-Version: 1.0 

65.  

66.   Name: ourbeans/Bidos.class 

67.   Java-Bean: True 

68.  

69.   Name: ourbeans/Bino.class 

70.   Java-Bean: True 

71.  

72.   Name: ourbeans/Bitres.class 

73.   Java-Bean: True 

74.  

75.   Name: ourbeans/OurBean.class 

76.   Java-Bean: True 

77. ================= 

78.   jar  cvf  some.jar  ourbeans/*.class 

79.  

80.