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.htm
<HTML>
<HEAD>
<SCRIPT language=JavaScript src=SimpleApplet.js></SCRIPT>
</HEAD>
<BODY BGCOLOR="000000" onload="createApplet()">
<CENTER>
<DIV ID=target></DIV>
</CENTER>
</BODY>
</HTML>
SimpleApplet.js
/**
* SimpleApplet.js
*
* @author bruno augier
* @email bruno.augier@dzzd.net
* @website http://dzzd.net/
* @version 1.00 2007/07/18
*/
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.java
/**
* SimpleApplet.java
*
* @author bruno augier
* @email bruno.augier@dzzd.net
* @website http://dzzd.net/
* @version 1.00 2007/07/18
*/
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class SimpleApplet extends Applet implements MouseMotionListener,Runnable
{
private int mousePosX; //Last know mouse pos x (relative to upper corner)
private int mousePosY; //Last know mouse pos y (relative to upper corner)
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();
}
}