小程序中的后台进程
我正在开发一个小程序,我想做一些事情,当我单击提交按钮时,如果后台进程正在运行,那么它应该表明进程正在后台运行并且无法执行任何其他操作。
我尝试过类似进度条的东西,但它需要在线程中进行编码。 我是 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
嘿,朋友,使用 Java swingworker 类
在doinbackground()方法中写入你的整个背景BL。
Hey frnd use Java swingworker class
write your whole background BL in doinbackground() method .
不管喜欢与否,您都必须习惯使用线程,因为这是在应用程序运行时更新 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
.您可以使用 Java JProgressBar 来实现此目的。
类似的东西:
有关更多详细信息:
参考
另外ProgressMonitor 可能是不错的选择。
You can use Java JProgressBar for this.
some thing like :
For more details :
Reference
Also ProgressMonitor may be the good option.