Hi,
 
I'm a very very novice in java.
 
Reading Steven Holzner's "Java 1.2 Learning by Examples" I found an example, which would be very
useful for me in my work.
 
After succesfully compiling I use the appletviewer to test the applet.
 
The gif file is loaded succesfully. But when I move the mouse all over the
image nothing happens. I would expect the mouse to show when it hits the x and y  coordinates.
 
Does anyone have an idea? 
 
TIA
 
Poul / The Danish National Institute of Social Research
 
 
The code is as follows:
 
 
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
 
public class imapx extends Applet implements MouseListener {
      Image Imap;
        public void init(){
            Imap = getImage(getCodeBase(), "bt_strategy.gif");
            addMouseListener(this);
            }
 
        public void mousePressed(MouseEvent e) {
              URL newURL = null;
                 int x = e.getX();
                 int y = e.getY();
                 if( x > 104 + 10 && x < 171 + 10 && y > 53 + 10 && y < 75 + 10)
                 {
                         try { newURL = new URL("http://www.prosa.dk");}
                           catch (MalformedURLException e1 ) {}
                            getAppletContext().showDocument(newURL);
                  }
                 if( x > 54 + 10 && x < 118 + 10 && y > 105 + 10 && y < 125 + 10)
                 {
                        try { newURL = new URL("http://www.sfi.dk");}
                           catch (MalformedURLException e2 ) {}
                            getAppletContext().showDocument(newURL);
                  }
           }
 
        public void mouseClicked(MouseEvent e){}
        public void mouseReleased(MouseEvent e){}
        public void mouseEntered(MouseEvent e){}
        public void mouseExited(MouseEvent e){}
        public void mouseMoved(MouseEvent e){}
 
        public void paint (Graphics g) {
               g.drawImage(Imap, 10, 20, 240, 155, this);
 
           }
}
 
 
 
 
 

Reply via email to