Hello I am trying to change the colors of my swing progress bar in java. Initially I tried using the following code:
UIManager.put("ProgressBar.selectionBackground", Color.black);
UIManager.put("ProgressBar.selectionForeground", Color.white);
UIManager.put("ProgressBar.background", Color.white);
UIManager.put("ProgressBar.foreground", Color.RED);
m_progressBar.setBackground(Color.BLACK);
m_progressBar.setForeground(Color.red);
But none of the commands seemed to have any effect!!!
Unless I set m_progressBar.stringPainted(true)
and then the foreground does change.
Anyhows I know that the problem arises from the following command: UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
which is invoked before the UI is initialized.
So my questions are:
1) Out of curiosity: why does the the stringPainted(true)
invocation manages to override foreground UI settings?
2) How do I keep UIManager.setLookAndFeel
in the beginning of the code and still override UI settings?
Thank you!!