/* 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 RightClickSw 

6.     extends JApplet 

7.     implements MouseListener 

8.

9.   String strpaint = "No click as yet"

10.   JPanel cp; 

11.  

12.   public RightClickSw () 

13.   { 

14.     cp = new JPanel() 

15.     { 

16.       public void paintComponent ( Graphics   gr ) 

17.       { 

18.         super.paintComponent(gr); 

19.         gr.drawString ( strpaint , 10 , 20 ); 

20.       } 

21.     }; 

22.     setContentPane( cp ); 

23.  

24.     cp.addMouseListener ( this ) ; 

25.     cp.setBackground ( Color.pink ) ; 

26.   } 

27.  

28.   public void  mouseClicked  ( MouseEvent  ev ) 

29.   { 

30.     String strclicksitu = "left button clicked"

31.     boolean meta ; 

32.  

33.     meta = ev.isMetaDown(); 

34.  

35.     if ( meta ) 

36.       strclicksitu = "right  button clicked or equivalent"

37.  

38.     strpaint = "The click situation is : "  + strclicksitu ; 

39.     cp.repaint (); 

40.   } 

41.   public void mousePressed( MouseEvent ev) { } 

42.   public void mouseReleased( MouseEvent ev) { } 

43.   public void mouseEntered( MouseEvent ev) { } 

44.   public void mouseExited( MouseEvent ev) { } 

45.