This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Making a mouse click in Java? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Making a mouse click in Java?" Watch "Making a mouse click in Java?" New topic
Author

Making a mouse click in Java?

Alex Richards
Greenhorn

Joined: Mar 07, 2011
Posts: 9
Hi, I've been trying to find a way to make a program in NetBeans IDE that can make your mouse click.
Does anyone have any idea on how I could go about coding this?
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11404
    
  81

Alex Richards wrote:Hi, I've been trying to find a way to make a program in NetBeans IDE that can make your mouse click.
Does anyone have any idea on how I could go about coding this?

I can read that two ways:
  • I wish to make NetBeans behave as though a mouse had just been clicked within the IDE
  • I wish to emulate mouse clicks in some other (unnamed) environment


  • Can you make your question a little clearer?


    The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
    Andrew Monkhouse
    author and jackaroo
    Marshal Commander

    Joined: Mar 28, 2003
    Posts: 11404
        
      81

    (I can also read this as you want to have my mouse click, in which case: stay away from my computer! )
    Alex Richards
    Greenhorn

    Joined: Mar 07, 2011
    Posts: 9
    I would like to write a program that simulates a mouse being clicked. (In other words, I'd like to be away from the computer while the program makes my mouse click ).
    I understand how I could write a loop to continuously make the mouse click, but I'm unsure of the code I would need to add in that loop to make the cursor simulate a mouse left-click.
    Alex Richards
    Greenhorn

    Joined: Mar 07, 2011
    Posts: 9
    And yes, I'd like it to be able to continue running, even if I had a different window open.
    (For example, I'd like to be able to open up the internet browser and have the mouse still continually be clicking.)
    Jesper de Jong
    Java Cowboy
    Saloon Keeper

    Joined: Aug 16, 2005
    Posts: 14074
        
      16

    I think you can do this with the class java.awt.Robot - look it up in the documentation.


    Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
    Scala Notes - My blog about Scala
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Making a mouse click in Java?
     
    Similar Threads
    Page Reload / Frame
    no mouseClicked when TransferHandler set for JLabel?
    Displaying a DIV wherever the mouse location is
    JComboBox Drag Problem
    how to make right click ?