Forcer le positionnement de la souris
De Centre de Ressources Numériques - Labomedia
import java.awt.AWTException;
import java.awt.Frame;
import java.awt.Robot;
Robot robot;
float angle;
int posX, posY;
void setup() {
size(400, 400);
smooth();
try {
robot = new Robot();
}
catch (AWTException e) {
e.printStackTrace();
}
angle = 0;
cursor(CROSS);
// noCursor();
mouseY = height / 2;
}
void draw() {
float variationY = mouseY - height / 2;
angle = angle + variationY / 200;
background(255);
translate(width / 2, height / 2);
rotate(angle);
ellipse(0, 0, 100, 100);
line(-100, 0, 100, 0);
Frame f = (Frame) ((processing.awt.PSurfaceAWT.SmoothCanvas) surface.getNative()).getFrame();
robot.mouseMove(f.getX() + width / 2, f.getY() + frame.getY() + height / 2);
}