This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Java in General and the fly likes do we hava any core java API which simulates left mouse click and release? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "do we hava any core java API which simulates left mouse click and release?" Watch "do we hava any core java API which simulates left mouse click and release?" New topic
Author

do we hava any core java API which simulates left mouse click and release?

linda russel
Ranch Hand

Joined: Jan 05, 2012
Posts: 86
could you please give me the name of the API if any?
Sumit Patil
Ranch Hand

Joined: May 25, 2009
Posts: 296

Its SwingUtilities class

Check this


Thanks & Regards, Sumeet
SCJP 1.4, SCWCD 5, LinkedIn Profile
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14278
    
  21

Maybe the java.awt.Robot class will be useful for this.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4642
    
    5

Sumit Patil wrote:Its SwingUtilities class

Check this


That isn't a method that
simulates left mouse click and release


luck, db
There are no new questions, but there may be new answers.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10486
    
    9

Technically speaking, a "click" is a press+release.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1794
    
    7

You could also create a new MouseEvent and post it to the system EventQueue manually.
To simulate a user clicking a mouse button you'd need to post two such events (MOUSE_PRESSED and MOUSE_PRESSED).
The java.awt.Robot class Jesper suggested would probably be a better option, though.

Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
linda russel
Ranch Hand

Joined: Jan 05, 2012
Posts: 86
i am trying to do the mouse click and release in HTML5 canvas. i am trying to do selenium automation.
dennis deems
Ranch Hand

Joined: Mar 12, 2011
Posts: 808
linda russel wrote:i am trying to do the mouse click and release in HTML5 canvas. i am trying to do selenium automation.

Selenium.click, .mouseDown, .mouseUp, etc. etc. -- these are insufficient for your test case?
linda russel
Ranch Hand

Joined: Jan 05, 2012
Posts: 86
problem is i am getting the id of the html5 canvas. but i do not know how to get a particular co-ordinates and do the processing there.
linda russel
Ranch Hand

Joined: Jan 05, 2012
Posts: 86


my smiley is not being drawn inspite of the following code!!! any ideas?
linda russel
Ranch Hand

Joined: Jan 05, 2012
Posts: 86





The first part of the code is written as a method in a common java file
The second part of the code is written as a call to that common method.
Ispite of these smiley is not drawn ?
Any idea of how to correct it?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: do we hava any core java API which simulates left mouse click and release?