Mohammad Adib
Mohammad Adib

Reputation: 818

Simulate right click

I am wondering how to make my Java program simulate a right click. So imagine your mouse cannot right click anymore. How do I make Java simulate the right click? Im planning to have a button that u press on a JFrame that simulates the right click after x seconds. Thanks and please try to include some code and not just links

Upvotes: 1

Views: 2577

Answers (3)

Andrew Thompson
Andrew Thompson

Reputation: 168795

Windows?

Control Panel | Ease of Access | Make the mouse easier to use | Control the mouse with the keyboard


As an aside. A mouse is usually less that $10. If your time is worth $20 an hour, you'd have to finish the code within 30 minutes to make it cheaper than buying a new mouse. This project seems a 'false economy'.

Upvotes: 2

camickr
camickr

Reputation: 324078

Im planning to have a button that u press on a jframe that simulates the right click after x seconds

button.doClick();

Upvotes: 2

corsiKa
corsiKa

Reputation: 82559

The java.awt.Robot api was designed for exactly this. It has lots of goodies in it!

Specifically in this case, mousePress and mouseRelease.

P.S. Yes I realize they're just links. But in all honesty, learning to read API docs and make code from them effectively is a skill every developer needs!

Upvotes: 12

Related Questions