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

3. import java.applet.*; 

4.  

5. public class RefTypes 

6.     extends Applet 

7.     implements MouseListener 

8.

9.   Component crefone, creftwo ; 

10.  

11.   public RefTypes ( ) 

12.   { 

13.     crefone = new Button ( "Don't click here" ) ; 

14.     creftwo = new TextField ( "Click the applet, please" ) ; 

15.   } 

16.  

17.   public void init ( ) 

18.   { 

19.     add ( crefone ) ; 

20.     add ( creftwo ) ; 

21.  

22.     addMouseListener( this ); 

23.   } 

24.  

25.   public void mouseClicked(MouseEvent e) 

26.   { 

27.     crefone.setBackground( Color.cyan ); 

28.     creftwo.setBackground( Color.yellow ); 

29.  

30.     Button bt = (Button)crefone ; 

31.     String s = bt.getLabel() ; 

32.     bt.setLabel( s.substring(7) ) ; 

33.  

34.     TextField tf = null

35.     if ( creftwo  instanceof  TextField

36.     { 

37.       tf = (TextField)creftwo ; 

38.       String st = tf.getText() ; 

39.       tf.setEchoChar('*') ; 

40.       tf.setText( st ); 

41.     } 

42.     removeMouseListener( this ); 

43.   } 

44.  

45.   public void mousePressed(MouseEvent e) {} 

46.   public void mouseReleased(MouseEvent e) {} 

47.   public void mouseEntered(MouseEvent e) {} 

48.   public void mouseExited(MouseEvent e) {} 

49.

50. ===========  Container.java  ==================== 

51.   public .... add ( Component comp ).... 

52.