Most guides and books will tell you that it is very easy to change the cursor in a Java application. For example, the following fragment of code sets the cursor to a busy cursor while it performs some processing, and then returns the cursor to the default cursor again afterwards.
// Setting cursor for any Component:
This is a good start but, somewhat surprisingly, this short code fragment contains a bug. The problem is that the main processing method might throw an exception. If the exception is not caught within the processing method, then the Java Virtual Machine unwinds the call stack repeatedly until it finds a try context that will catch the given exception. In other words, the flow of control may jump out of this (apparently) linear flow of control and we therefore cannot guarantee that the default cursor is restored. In short, if an exception is thrown, the busy cursor will remain there indefinitely!