tags:

views:

910

answers:

2

I have created this applet, It moves mouse to 1000 pos on screen.It works as application but it does not work in applet. I have created signed applet but still it wont move mouse. What should i do to make my robot class work from browser .

import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Robot;
import java.awt.AWTException;
public class s extends Applet {
public  void paint(Graphics g){
 g.drawString("Test1", 10, 10);

}
 public void init(){
  try{
     Robot robot = new Robot();
     robot.mouseMove(1000,50);
     System.out.println("code executes");
  }catch(Exception ex){

    System.out.println("code failed");
  };

 }

}
+2  A: 

Signing alone won't give your Applet any permissions. You need to grant the createRobot permission to your Applet.

Check the security tutorials for more details.

Joachim Sauer
A: 

I've checked the source-code from Robot. And I think you have to add in the constructor a ScreenDevice.

Martijn Courteaux