开发者

JProgressBar with double value

Hello i would like to know if i can extends a JProgressBar to use double value for min max, instead o开发者_运维技巧f int. Thank you.


If you know the bounds and precision of your values, it's quite easy to do with a wrapper. I've used this approach for a computationally intensive application where 1% equates to about 30 seconds. Showing a JProgressBar with min=0 and max=100 didn't give enough feedback. Users thought the application was hung.

Solution: Scale the values

I had a float (0f - 1f) that represented the actual percent complete. By multiplied that by 10000 I got an integer range of 0 - 10000. I set up JPB with min=0 and max=10000.

Then just a call to setString(NumberFormat.getPercentInstance().format(value)) to display the formatted percent.


Sure you can, but for what purpose? How do you display a half percent?

You can however use the setString()-method to display the more exact value. Printing the String must be turned on using the setStringPainted()-method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜