
454
|
Chapter 12, Miscellany
#91 Check Your Mail with Swing
HACK
moveMouse(delete, delete, 1000);
moveMouse(delete, showme, 500);
} catch (Exception ex) {
System.out.println(""+ex);
}
}
The event handler moves the cursor from the
showme
button, which is where
the cursor will already be anyway, to the
info toolbar button over a period
of two seconds. After that, the cursor will hop from button to button taking
one second to move with a one second pause over each button. Finally, the
cursor rushes back to the
showme button in a half-second. It is important to
return the cursor to its starting position so that the user won’t have to hunt
for it after the animation is complete. It’s best to always return things to the
state you found them.
H A C K
#91
Check Your Mail with Swing Hack #91
Add email checking to your application with just a few method calls.
As email becomes a bigger part of our daily lives, I have seen it creep into
more and more places. My email program alerts me when there is new mail.
I can check my email via the phone. I log in to my web mail from an Inter-
net cafe. Email is everywhere, so why shouldn’t it be in your Swing applica-
tion? This hack shows how to embed in your application an email checker
that shows the current number of unread messages and can launch the
user’s email application.
Dealing with email servers can be a complicated and tricky business. To
help address these issues, ...