I created this applet, it moves the mouse 1000 positions on the screen. It works as an application, but it does not work in the applet. I created a signed applet, but it still won’t move the mouse. What should I do to make my Robot class work from a browser? My code is as follows:
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");
};
}
}
source
share