I want to draw a horizontal line with mouse into a canvas. The mouse is moving, but the line isn't drawn.

Robot robot = new Robot();
robot.delay(2000);
robot.mouseMove(600, 400);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
Thread.sleep(5000);
robot.mouseMove(650,400);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);

What's missing?