小程序中的后台进程

发布于 2025-01-02 08:43:04 字数 156 浏览 5 评论 0原文

我正在开发一个小程序,我想做一些事情,当我单击提交按钮时,如果后台进程正在运行,那么它应该表明进程正在后台运行并且无法执行任何其他操作。

我尝试过类似进度条的东西,但它需要在线程中进行编码。 我是 Java 新手,所以有没有其他方法可以做到这一点,或者我必须仅借助线程来做到这一点?

I am developing an applet and I want to do something that when I click a submit button then if a background process in running then it should indicate that a process is running in background and unable to do anything else.

I have tried something like progress bar but it needs to have coding in threads.
I am new in Java, so is there any other way to do this or I have to do it with the help of threads only?

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

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

发布评论

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

评论(3

纵山崖 2025-01-09 08:43:04

嘿,朋友,使用 Java swingworker 类
doinbackground()方法中写入你的整个背景BL。

Hey frnd use Java swingworker class
write your whole background BL in doinbackground() method .

薆情海 2025-01-09 08:43:04

不管喜欢与否,您都必须习惯使用线程,因为这是在应用程序运行时更新 GUI 元素的唯一方法。正在做处理。

但不必惊慌,Java 有一些方便的类可以为您处理大部分线程管理。特别参见 SwingWorker

Like it or not, you'll have to get used to working with threads, since it is the only way to get a GUI element to update while the app. is doing processing.

But no need to panic, Java has some handy classes that handle most of the thread management for you. See particularly the SwingWorker.

忆梦 2025-01-09 08:43:04

您可以使用 Java JProgressBar 来实现此目的。
类似的东西:

  JProgressBar pb = new JProgressBar(0, 20);
  pb.setValue(0);
  pb.setStringPainted(true);

有关更多详细信息:

参考

另外ProgressMonitor 可能是不错的选择。

You can use Java JProgressBar for this.
some thing like :

  JProgressBar pb = new JProgressBar(0, 20);
  pb.setValue(0);
  pb.setStringPainted(true);

For more details :

Reference

Also ProgressMonitor may be the good option.

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