如何在java中发送电子邮件时显示进度条

发布于 2024-08-25 22:58:42 字数 47 浏览 4 评论 0原文

大家好 我想显示进度条 当我的程序发送电子邮件时

我该怎么做?

hii every one
I want to show progress bar
while my program sends email

how can i do it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

千と千尋 2024-09-01 22:58:42

显示带有沙漏或条纹加载栏或类似内容的简单 gif 图像。由于这将是单步操作,因此您实际上无法告诉用户 N% 已完成。添加带有超时的回调来验证操作是否成功。显示图像的方式取决于您使用的技术。

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.

長街聽風 2024-09-01 22:58:42

Swing 的 JProgressBar 可能是小程序的最佳选择。

当您不知道操作需要多长时间时,它有一个模式。

对于 JavaMail,您可以使用 TransportListener 监听传输系统(可能是 com.sun.mail.smtp.SMTPTransport),它会告诉您至少每封邮件何时发送,这样您就可以为多个收件人执行进度。

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.

一个人的旅程 2024-09-01 22:58:42

您需要将两个类放在一起, JProgressBar< /a> 用于 UI,以及 SwingWorker 用于后台线程。从您的评论来看,您首先需要查看 SwingWorker 教程

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.

清旖 2024-09-01 22:58:42

根据本机/网络应用程序、单个电子邮件/多个电子邮件,解决方案可能略有不同。

例如,Web 应用程序+单个电子邮件,请考虑使用动画 gif,同时在另一个 iframe 中发送电子邮件。

例如webapp+多封邮件,每封邮件发送后,进度条可以根据已发送邮件数/邮件总数,持续显示完成百分比。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文