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

2. import java.awt.event.*; 

3. import java.awt.*; 

4.  

5. public class AdaptSw 

6.     extends JApplet 

7.

8.   int count = 0

9.  

10.   class MA 

11.     extends MouseAdapter 

12.   { 

13.     public void mouseClicked ( MouseEvent  ev ) 

14.     { 

15.       count++; 

16.       repaint(); 

17.     } 

18.   } //end MA 

19.  

20.   public AdaptSw() 

21.   { 

22.      setContentPane( new Content() ); 

23.   } 

24.   class Content 

25.     extends JPanel 

26.   { 

27.     Content() 

28.     { 

29.       addMouseListener ( new MA() ) ; 

30.     } 

31.     public void paintComponent ( Graphics  gr ) 

32.     { 

33.       super.paintComponent( gr ); 

34.       gr.drawString ( "Counter : " + count , 75, 30  ); 

35.     } 

36.   } //end Content 

37.