how can i show progress bar while sending an email in java
hii every one I want to show progress bar while my program开发者_高级运维 sends email
how can i do it?
Display a simple gif image with hourglass or striped loading bar or something similar. Since this will be a single step operation you can't actually tell the user N % complete. Add a callback with timeout to verify the success of the operation. How you display the image depends on what technology you are using.
Swing's JProgressBar is probably your best bet for an applet.
It has a mode for when you don't know how long an operation will take.
For JavaMail you can listen to the transport system (probably com.sun.mail.smtp.SMTPTransport) with a TransportListener which will tell you when each message has been sent at least, so you can do progress for multiple recipients.
You need to put together two classes, JProgressBar for the UI, and SwingWorker for the background thread. From your comments, it looks like you first need to be looking at a SwingWorker tutorial.
depending on native/webapp, single email/multiple emails, solutions might be slightly different.
e.g webapp+single email, consider a animated gif, while you do send the email in another iframe.
e.g. webapp+multiple email, a progress bar can continuously display the percentage done, based on a number of sent emails/total emails, after each email get sent.
精彩评论