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

3. import java.awt.event.*; 

4.  

5. public class Images2 

6.     extends JApplet 

7.

8.   Image img ; 

9.   public Images2() 

10.   { 

11.     setContentPane( new Img2Content() ); 

12.   } 

13.   public void init( ) 

14.   { 

15.     img = getImage( getCodeBase(), "trans.gif" ) ; 

16.   } 

17. //================= 

18.   class Img2Content 

19.     extends JPanel 

20.       implements MouseListener 

21.     { 

22.     int x = 20

23.  

24.     Img2Content() 

25.     { 

26.       setBackground ( Color.orange ) ; 

27.       addMouseListener (this); 

28.     } 

29.  

30.     public void paintComponent ( Graphics gr ) 

31.     { 

32.       if ( img.getWidth( Images2.this ) == -1 ) return

33.  

34.       super.paintComponent( gr ); 

35.  

36.       for ( int i = 0 ; i < 500 ; i+=20

37.         gr.drawLine ( 250,300, i,0 ); 

38.  

39.       gr.drawImage ( img, x , 20

40.         img.getWidth(null), img.getHeight(null), null ); 

41.     } 

42.  

43.     public void mouseClicked ( MouseEvent e ) 

44.     { 

45.       x += 5

46.       repaint() ; 

47.     } 

48.     public void mousePressed(MouseEvent e)  {} 

49.     public void mouseReleased(MouseEvent e)   {} 

50.     public void mouseEntered(MouseEvent e)   {} 

51.     public void mouseExited(MouseEvent e)  {} 

52.   } 

53. //=============== 

54.