e804. displaying the percentage done on a jprogressbar component.txt

来自「这里面包含了一百多个JAVA源文件」· 文本 代码 · 共 14 行

TXT
14
字号
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 Creating a JProgressBar Component with an Unknown Maximum). 

    // 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 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?