e803. getting and setting the values of a jprogressbar component.txt

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

TXT
30
字号
// To create a progress bar, see e801 Creating a JProgressBar Component
    
    // Get the current value
    int value = progress.getValue();
    
    // Get the minimum value
    int min = progress.getMinimum();
    
    // Get the maximum value
    int max = progress.getMaximum();
    
    
    // Change the minimum value
    int newMin = 0;
    progress.setMinimum(newMin);
    
    // Change the maximum value
    int newMax = 256;
    progress.setMaximum(newMax);
    
    // Set the value; the new value will be forced into the bar's range
    int newValue = 33;
    progress.setValue(newValue);

It is also possible to set all the values at once by using the model: 
    progress.getModel().setRangeProperties(newValue, 0, newMin, newMax, false);

 Related Examples 

⌨️ 快捷键说明

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