Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / May 2004

Tip: Looking for answers? Try searching our database.

JProgressBar selectionForeground/backGround

Thread view: 
Sean Pinto - 11 May 2004 00:02 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
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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.