I'm writing an swing app and i'd like to have 'wait' cursor when some methods are executed. We can do it this way:
public void someMethod() {
MainUI.getInstance().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
//method code
MainUI.getInstance().setCursor(Cursor.getDefaultCursor());
}
What I'd like to achieve is a java annotation, that would set wait cursor before method execution and set it back to normal after execution. So previous example would look something like this
@WaitCursor
public void someMethod() {
//method code
}
How can i achieve this? Suggestions about other variants of solving this problem are also welcome. Thanks!
P.S. - We use Google Guice in our project, but i don't get how to solve the problem using it. If someone would provide me with simple example of similar problem, that would be very helpful