After searching around the net for the answer I believed that I had
found out how to change the colors of the text in the JProgressBar via
UIManager.put("ProgressBar.selectionForeground", new
ColorUIResource(Color.BLACK)) and ("ProgressBar.selectionBackground",
new ColorUIResource(Color.BLACK)) however this doesn't work. Does
anyone know what I am doing wrong I have attached my code.
// FirstScreen.java
package PropertyManager;
import Utilities.SLOConstants;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.plaf.ColorUIResource;
public class FirstScreen extends JWindow
{
private int timerClock;
private int timerLength;
private JProgressBar progBar;
public FirstScreen(int numSecs)
{
this.timerLength = numSecs * 1000;
this.timerClock = 0;
this.progBar = new JProgressBar(JProgressBar.CENTER, 0,
this.timerLength);
Color orange = new Color(255, 122, 56);
Color lightOrange = new Color(255, 182, 147);
JPanel content = (JPanel) getContentPane( );
content.setBackground(Color.white);
int width = 530;
int height =300;
Dimension screen = Toolkit.getDefaultToolkit( ).getScreenSize( );
int x = (screen.width-width)/2;
int y = (screen.height-height)/2;
setBounds(x,y,width,height);
JLabel label = new JLabel(new ImageIcon(SLOConstants.IMAGES_PATH +
"splashLogo.gif"));
progBar.setString("Initializing Property Manager ... Please Wait");
progBar.setStringPainted(true);
progBar.setForeground(orange);
progBar.setBackground(orange);
UIManager.put("ProgressBar.selectionBackground", new
ColorUIResource(Color.BLACK));
UIManager.put("ProgressBar.selectionForeground", new
ColorUIResource(Color.BLACK));
progBar.setFont(new Font("Arial", Font.BOLD|Font.ITALIC, 17));
progBar.setBorder(BorderFactory.createLineBorder(orange, 0));
progBar.setBorderPainted(false);
content.add(label, BorderLayout.CENTER);
content.add(progBar, BorderLayout.SOUTH);
content.setBorder(BorderFactory.createLineBorder(orange, 5));
}
public void showSplash( )
{
setVisible(true);
for( timerClock = 0; timerClock < timerLength; timerClock += 10 )
{
progBar.setValue(timerClock);
try
{
Thread.sleep(10);
}
catch(Exception e){}
}
}
public void showSplashAndClose( )
{
showSplash( );
dispose();
}
public static void main(String[] args)
{
//FirstScreen splash = new FirstScreen(2);
}
}
Alan Moore - 11 May 2004 12:20 GMT
>After searching around the net for the answer I believed that I had
>found out how to change the colors of the text in the JProgressBar via
[quoted text clipped - 92 lines]
> }
>}
If you want to override default settings in UIManager, you have to do
it before you create any GUI components. In this case, I would
suggest doing it in the main() method, before you call the
constructor.