Reputation: 818
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
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
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
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