package netscape.dts.examples.HitMan; import java.awt.*; import java.applet.Applet; import netscape.javascript.*; public class HitManApplet extends Applet { int numHits=0; public void paint( Graphics g ) { Rectangle boundsRect = this.bounds(); g.drawRect( boundsRect.x, boundsRect.y, boundsRect.width-2, boundsRect.height-2); g.drawString( "Hit Them!", 30, 30 ); } public boolean mouseDown(Event evt, int x, int y) { HitThem(); return true; } public void HitThem() { JSObject window = JSObject.getWindow( this ); JSObject document = (JSObject) window.getMember("document"); JSObject applets = (JSObject) document.getMember("applets"); int numApplets = ((Number) applets.getMember("length")).intValue(); targetLoop: for( int index = 0; index < numApplets; index++ ) { Object theApplet = applets.getSlot( index ); VictimApplet targetApplet = null; try { targetApplet = (VictimApplet) theApplet; } catch( ClassCastException e ) { continue targetLoop; } targetApplet.hit(); } } }