e804. 显示JProgressBar的完成百分率

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
posted @ 2018-09-06 08:59  borter  阅读(140)  评论(0编辑  收藏  举报