this is a simple workaround to avoid "click to activate control", working on IE7
juste create the 3 following files with th right name, compile it & try it!
SimpleApplet.htm1 2 3 4 5 6 7 8 9 10
| <HTML> <HEAD> <SCRIPT language=JavaScript src=SimpleApplet.js></SCRIPT> </HEAD> <BODY BGCOLOR="000000" onload="createApplet()"> <CENTER> <DIV ID=target></DIV> </CENTER> </BODY> </HTML> |
SimpleApplet.js1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
function createApplet() { var elem=document.getElementById("target"); html="<APPLET\n"; html+="code = 'SimpleApplet.class'\n" ; html+="width = '600'\n"; html+="height = '360'\n"; html+="></APPLET>\n" ; elem.innerHTML=html; setTimeout("focusApplet()",1000); }
function focusApplet() { if(document.applets[0]!=null) { document.applets[0].focus(); document.applets[0].click(); } else setTimeout("focusApplet()",1000); }
|
SimpleApplet.java1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
| import java.awt.*; import java.applet.*; import java.awt.event.*;
public class SimpleApplet extends Applet implements MouseMotionListener,Runnable { private int mousePosX; private int mousePosY; private boolean run; public void init() { this.run=true; this.addMouseMotionListener(this); Thread t=new Thread(this); t.start(); } public void run() { try { while(this.run) { this.update(this.getGraphics()); Thread.sleep(10); } } catch(InterruptedException ie) { } } public void destroy() { this.run=false; try { Thread.sleep(100); } catch(InterruptedException ie) { } } public void update(Graphics g) { g.setColor(new Color(0x000000)); g.fillRect(this.mousePosX, this.mousePosY,2,2); } public void paint(Graphics g) { } public void mouseDragged(MouseEvent e) { } public void mouseMoved(MouseEvent e) { this.mousePosX=e.getX(); this.mousePosY=e.getY(); }
}
|