
import java.awt.*;
import java.applet.*;
import netscape.javascript.*;

/**
 * Berechnung des Offset eines Applets in einer HTML-Seite. 
 * Funktioniert nur mit einem InternetExplorer.
 * @author  Mark Donnermeyer
 */
public class AppletPositionExplorer extends AppletPosition {
    
    Applet appl;
    String applName;
    
    public AppletPositionExplorer(Applet appl, String applName)
    {
        this.appl = appl;
        this.applName = applName;
    }
    
    public Point getPosition() {
        
        Point pos = new Point(0,0);
        JSObject winObj = JSObject.getWindow( appl);
        JSObject docObj = (JSObject)winObj.getMember("document");
        JSObject appObj = (JSObject)docObj.getMember(applName);

        pos.y = (int)Double.valueOf(""+appObj.getMember("offsetTop")).doubleValue();
        pos.x = (int)Double.valueOf(""+appObj.getMember("offsetLeft")).doubleValue();

        return pos;
    }
}
