问题
Hello i would like to know if i can extends a JProgressBar
to use double value for min max, instead of int.
Thank you.
回答1:
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.
回答2:
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.
来源:https://stackoverflow.com/questions/6579789/jprogressbar-with-double-value