// BunsenMap.java
// Demonstrates an image map
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class BunsenMap extends JApplet {
        ImageIcon mapBunsen;
        int w, h;

        public void init ( ) {
                mapBunsen = new ImageIcon( "images/bunsen23.jpg" );
                w = mapBunsen.getIconWidth( );
                h = mapBunsen.getIconHeight( );
                setSize( w, h );

                addMouseListener(
                        new MouseAdapter( ) {
                                public void mouseExited( MouseEvent e ) {
                                        showStatus( "Pointer outside applet" );
                                }
                        }
                );

                addMouseMotionListener(
                        new MouseMotionAdapter( ) {
                                public void mouseMoved( MouseEvent e ) {
                                        showStatus( translateLocation( e.getX( ), e.getY( ) ) );
                                }
                        }
                );                      
        }

        public void paint( Graphics g ) {
                mapBunsen.paintIcon( this, g, 0, 0 );
        }
        public String translateLocation( int x, int y ) {
                if ( ( x >= 77 && x <= 102 ) && ( y >= 112 && y <= 170 ) )
                        return "Click on my tie";
                else
                        return "Prof. Stephen G. Buell";
        }
}