The progress bar offers the ability to display the actual value of the bar as a percentage. This example demonstrates how to enable this display.
Note: The percentage display should not be enabled when the maximum is not known (e802 创建一个位置大小的JProgressBar组件).
// Create a horizontal progress bar int minimum = 0; int maximum = 100; JProgressBar progress = new JProgressBar(minimum, maximum); // Overlay a string showing the percentage done progress.setStringPainted(true);
Related Examples |