I tried out the function of the JProgressBar in Java. But there is a problem I couldn't solve:
When I set the minimum to zero, the maximum value to 100 and the current value to 6 then nothing will be displayed. The progress bar is empty. If I put 7 as current value then it works. It seems to be a problem with any empty border or other space. The problem occurs with Windows 7 and only if the UIManager is set to SystemLookAndFeel.
Does anyone knows this problem and has a solution for this? Below is my code:
package lab;
import java.awt.FlowLayout;
import javax.swing.JDialog;
import javax.swing.JProgressBar;
import javax.swing.UIManager;
import core.Config;
public class ProgressSample extends JDialog {
public ProgressSample() {
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
getContentPane().setLayout(new FlowLayout());
// Nothing is displayed
JProgressBar progressSix = new JProgressBar(0, 100);
progressSix.setValue(6);
getContentPane().add(progressSix);
// This works
JProgressBar progressSeven = new JProgressBar(0, 100);
progressSeven.setValue(7);
getContentPane().add(progressSeven);
pack();
}
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager
.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
ProgressSample dialogTest = new ProgressSample();
dialogTest.setVisible(true);
}
}