I want to use the Robot class in a java applet to move a web browser and click

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");
                };
        }
}
+4
source share
2 answers

Only signing will not give your Applet any permissions. You need to provide permission createRobotfor your applet.

Read the safety guides for more information .

+2
source

Robot. , ScreenDevice.

0

All Articles