将jprogressbar分配给任务? [英] Assigning a jprogressbar to a task?

查看:70
本文介绍了将jprogressbar分配给任务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个工作程序,它使用复选框让用户选择特定目录,在用户按下按钮后,所选目录将被清除。



我现在要做的是制作当前无功能的进度条,填满目录被清除。我已经无数次查看过JProgressBar上的Java文档,以及观看有关制作和使用进度条的无数教程,但到目前为止所有内容只显示如何手动设置进度条的值和消息,而不是如何将它分配给任务的实际部分。



我的问题是,我将在哪里放入进度条的不同命令,以使其成为一个功能进度条,而不仅仅是一个无论发生什么都会填满的酒吧。例如,我将如何制作它,以便当特定目录有很多要删除的时间,并且需要一段时间后,进度条开始填充得更慢?如果目录中几乎没有任何内容,则反之亦然。



我尝试过:



我还没有尝试过任何东西。

I have a working program, which uses check boxes to let the user select specific directories, and after the user presses a button, the selected directories are cleared.

What I want to do now, is make the currently non-functional progress bar, fill up as the directories are being cleared. I've looked over the Java documentation on JProgressBar countless times, as well as watching countless tutorials on making and using a progress bar, but everything so far just shows how to manually set the value and message of the progress bar, and not how to assign it to an actual part of a task.

My question is, where would I put in the different commands for the progress bar, in order to make it a functional progress bar, rather than just a bar that fills up no matter what happens. For example, how would I make it, so that when a specific directory has a lot to delete, and it takes it a while, the progress bar starts to fill up more slowly? and vise versa for if a directory has almost nothing in it.

What I have tried:

I have not tried anything yet.

推荐答案

您必须根据您尝试处理的数据计算填充率。大多数系统通过不断对数据进行采样以获得处理与未处理的比率以及每秒/分钟的实际速率等来实现此目的。
You have to calculate the rate of fill, based on the data you are trying to process. Most systems do this by continually sampling the data to get the ratio of processed to unprocessed, and the actual rate per second/minute etc.


这篇关于将jprogressbar分配给任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆