// We create a Mouse event by using the Robot. Warning that the mouse position will be forced on the screen final Pane pane = (Pane) layer.getRootWindow(RendererKey.DEFAULT); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); try { final Robot robot = new Robot(ge.getDefaultScreenDevice()); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { int pos = PainterUtils.floatToPixelsX(5000f); javafx.geometry.Point2D p = pane.localToScreen(pos, pos); robot.mouseMove((int) p.getX(), (int) p.getY()); robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); } }); } catch (Exception e) { e.printStackTrace(); } // just to be sure that the event queue is taken into account try { Thread.sleep(200); } catch (InterruptedException ex) { ex.printStackTrace(); }
final Container cont = (Container) display.getRenderer(); // We create a Mouse event by using the Robot. Warning that the mouse position will be forced on the screen GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); try { final Robot robot = new Robot(ge.getDefaultScreenDevice()); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { int pos = PainterUtils.floatToPixelsX(5000f); Point p = new Point(pos, pos); SwingUtilities.convertPointToScreen(p, cont); robot.mouseMove(p.x, p.y); } }); } catch (Exception e) { e.printStackTrace(); } // just to be sure that the event queue is taken into account try { Thread.sleep(200); } catch (InterruptedException ex) { ex.printStackTrace(); }
Copyright 2016-2017 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v2 licence