I'm using the Robot class to perform mouse functions in my program, however I've encountered an issue with it swallowing the InterruptedException and printing the stack trace. This is not good because I need the interrupted status to be preserved.
I've found the issue occurs specifically in the delay() function of the Robot class, which is called internally:
public synchronized void delay(int ms) {
checkDelayArgument(ms);
try {
Thread.sleep(ms);
} catch (InterruptedException ite) {
ite.printStackTrace();
}
}
The function is public so I was able to create a custom class that extends Robot and override this method to include Thread.currentThread.interrupt();
in the catch block, however I consider this a nasty hack which may have repercussions. Is there a better way to handle this issue?