Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

How to invoke mouse clicked event?

Posted on 2001-06-27
Last Modified: 2012-05-04
i want to write a program where this program will move the mouse to certain location and then clicked on the specified location. any idea how to do this??? i'm developing this programming using Java.

may be somebody can tell me what method i should use to invoke the mouse clicked event.

thank you.
Question by:pleasure

Accepted Solution

yuri1976 earned 10 total points
ID: 6234293
have a look at the java.awt.Robot class

Here's an example:

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class TestRobot {

  public TestRobot() {

  public static void main(String[] args) {
    final JFrame frame = new JFrame("Test Robot");

    JPanel panel = new JPanel();
    JButton button = new JButton("Double click toolbar");
    button.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent ev) {
        try {

          Robot robot = new Robot();
          Point point = frame.getLocationOnScreen();
          Point titleBarCoord = new Point(point.x+50, point.y+8);

          robot.mouseMove(titleBarCoord.x, titleBarCoord.y);

        } catch (AWTException ex) {
          System.out.println("Error using Robot");

Author Comment

ID: 6237107
it's works..thank you

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Should localization be done inside spring controller 5 32
jdbc error in jsp application 20 63
Java: The Public Class Main 4 32
learn programming 8 39
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question