So I am working on creating a bot to automate a process for me, I don't have any problem moving the mouse around and clicking stuff. However, I only want the mouse to be able to move inside of a JPanel. How would this be possible?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
So I am working on creating a bot to automate a process for me, I don't have any problem moving the mouse around and clicking stuff. However, I only want the mouse to be able to move inside of a JPanel. How would this be possible?
If you only want to move the mouse programmatically within a restricted rectangle, then tell us where you're stuck in this process.
If you want to prevent the user from moving the mouse outside of a defined rectangle, then for this you would require either JNI or JNA to make platform calls. Of necessity any solution would be platform-specific. On a side note, I would not want to be a user of your program to find that my mouse has been restricted to a box.
Also, if you need to find the dimensions of the outside application, then (I believe) you would need to again make platform/OS calls, and again this may require use of JNI or JNA (or some outside library, such as AutoIt if this is Windows).
Last edited by Fubarable; July 4th, 2012 at 03:50 PM.