title: How can I trigger a click event on a Component using the Robot class?
body: <p>I need to trigger a MouseEvent mouseClicked on a JLabel (or any other component for that matter). How do I do this?</p>
  
  <p>I tried it using the Robot class as follows:</p>
  
  <pre><code>try {
      Robot r=new Robot();
      r.mouseMove(jl.gettX(), jl.getY());//jl is the JLabel
      r.mousePress(InputEvent.BUTTON1_MASK);
      r.mouseRelease(InputEvent.BUTTON1_MASK);
  } catch (AWTException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
  }
  </code></pre>
  
  <p>but the <code>getX()</code> and <code>getY()</code> are returning the <code>x,y</code> positions of the component's parent. How do I get the absolute position of a component so that I can trigger <code>Robot.mousePress()</code>? Is there any other way to trigger the event on a specific component?</p>